Re: php sessions question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reinhart Viane wrote:

in a page checkuser i do this after the user is logged in:
PHP Code
// Register some session variables!
session_register('userid');
$_SESSION['userid'] = $userid;
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('user_level');
$_SESSION['user_level'] = $user_level;


You should only save the userId in the session, everything else should be retrieved from your database using that id.



Now let's say user 1 logs in, his session is registered (with userid from database is 5 and first_name is XXX)
Then another user logs in, again his session is registered (with userid from database is 1 and first_name is YYY)




Are both user's in the same computer? then there may be a question about the old cookie being sent back to the server (if it's expiration time has not been exceeded). If the users are not using the same computer the chances are you have a bug in your code.

Now user 1 leaves the pages (closes the browser) and user 2 uploads a document (with my own script).

When the document is succesfully uploaded i display this:
PHP Code
echo ($_SESSION['first_name']).", the document has been succesfully added";
echo ($_SESSION['userid']);




This results in the folowing output:
YYY, the document has been succesfully added
5

Meaning the $_SESSION['first_name'] is correct, but the $_SESSION['userid'] is the one of the user who logged out...

Now when using user_id in all places it seems to work correctly...

Is userid something that is defined by the server when making sessions?


no.

If not, i don't have any clue what is going wrong...
Can someone help me on this? So i know what is wrong?



Thx in advance

Pout





--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux