HabboxWiki needs you!
Are you a Habbo buff? Or maybe a rare trader with a bunch of LTDs? Get involved with HabboxWiki to share your knowledge!
Join our team!
Whether you're raving for rares, excited for events or happy helping, there's something for you! Click here to apply
Need a helping hand?
Check out our guides for all things to help you make friends, make rooms, and make money!


Results 1 to 8 of 8

Thread: PHP Security

  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default PHP Security

    Hey,

    I just have some questions on PHP login security,

    How would I make a login script secure?

    Say if I made 5 different sessions on login and check the sessions all the way through would that be secure enough?

    Dan


  2. #2
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    no. Cos then if you have a script checking if the sessions exist then it will still think they're logged in even if theyre banned/their account has bin deleted...

    But if you make them expire after a set time or make it check their account still exists on ever refresh then you're all good.

  3. #3
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Some key ideas.

    - Have an online table and make a session that perhaps refers to that. Store the users IP ADDRESS in it, so that any other platform that has perhaps stolen a session cannot use it. That is known as protection from Session Hijacking.
    - Have timeouts. Not too short like Paypal but have them.

  4. #4
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    Thanks guys. Ok, How would a timeout script work? Any Eg's please =)


  5. #5
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Well, if you make a sessions for example
    $_SESSION["logintime"] = time();
    make it set that when they login, then make a new php file and make sure you include it in the file you want them to check the login so use
    include("checklogin.php");
    Now in that file put:
    <?php
    if($_SESSION["logintime"] < time() - 86400) {
    header("Locationogout.php");
    }else{
    $_SESSION["logintime"] = time();
    }
    That will check if they need to be logged out...

    if($username != "") {
    $real = mysql_query("SELECT * FROM `staff` WHERE `username`='$username'") or die ("Error! Please reinstall the panel.");
    }
    $check = mysql_num_rows($real);
    if($check == "0") { header("Locationogout.php"); }
    Thats a simnple way of checking if their account still exists, if not log them out...

  6. #6
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    So where does $username come from, cause in that instance it doesnt exist at all. Also the variable $check would equal false if $username was equal to nothing. Doesn't seem like you thought any of that through.
    Hi, names James. I am a web developer.

  7. #7
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    my apologies for a typo...
    <?php
    $username = $_SESSION["username"];
    if($username != "") {
    $real = mysql_query("SELECT * FROM `staff` WHERE `username`='$username'") or die ("Error! Please reinstall the panel.");
    }
    $check = mysql_num_rows($real);
    if($check == "0") { header("Locationogout.php"); }
    ?>

  8. #8
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Again where have you set $_SESSION["username"]; ?
    Hi, names James. I am a web developer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •