Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default How do i set a session via php

    Ok i'm wanting to know how to set a session in php?
    it needs to contain username and users password :S

    Just im trying to learn.

  2. #2
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    If you have a variable called $username you'd just set it by going

    PHP Code:
    <?php

    $_SESSION
    ['username'] = "$username";

    ?>

  3. #3
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    bloody hell thats pretty easy, would i do this for all or could i do it so its selects user from db then $username[username] $username[level] etc? or how would i go about this?

  4. #4
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    You'd need to have a seperate session for each one I believe, but you could define somewhere a function that creates one for each session, then it'd be $username("level") etc.

  5. #5
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    Cheers

  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Make a SESSION for the users id/username.

    Then just make a function which grabs the specific data from the MySQL table using their username/id.

    That's one way of doing it.

  7. #7
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    surely thats hackable?! without providing a corrct pwrd :S

  8. #8
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    surely thats hackable?! without providing a corrct pwrd
    How would it be exploitabe? O_O

    You set a session with their ID/Username once they login correctly.

    Then later on in your script, if you want to get say, their email you do like:

    getInfo("email");

    (obviously, you'd need to code the function).

    How could that be exploited by a USER?

  9. #9
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    is there anyway u can change the session eg change the username and id :S so u can get on someone else acc?

  10. #10
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Suggestion:

    If you're using sessions for a web app, only store the users UID in a session, as this is unlikely to change for their use of the app.

    You can make a function that automatically grabs the user details from the database (using their ID), and puts it in an array, like so:

    PHP Code:
    <?PHP

    function check_user_details() {

        
    $uid $_SESSION['uid'];

        
    $query "SELECT * FROM `users` WHERE uid='$uid'";
        
        
    $query mysql_query($query);
        
        
    $user mysql_fetch_assoc($query);
        
        return 
    $user;
        
        }
        
    $user check_user_details();
        
    ?>
    That way, you have access to the user details, and they are fresh (ie. if the username, email, password etc is changed, they will be refreshed after each load).

Page 1 of 2 12 LastLast

Posting Permissions

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