on 07/03/03 5:45 PM, Joe Wong ([EMAIL PROTECTED]) wrote: > Hello, > > I have two questions about using sessions in PHP. > > Firstly, I use session to remeber the username and a session ID for the > given user. When I hit the BACK button on the browser (IE), it always set > that my page is expired and ask me to click the refresh button. How to > prevent this from happening?
That sounds like a problem with POSTed data from forms, not necessarily a problem with sessions, or a problem a browser. Have you got a URL we can play with? > Secondly, how is the PHP session ID be computed? When user A login, a > session is started and his name nad session ID are stored. Now, on the same > PC, I start another instance of the IE browser, login as User B, her name > and session ID are stored under the same PHP session file. I switch back to > the Windows of User A and continue to do something, the PHP session gives me > the name of User B and User'B session ID. Why? Am I doing something wrong > here? Definitely. - enable cookies on your browser - make sure you're using PHP >= 4.1 1. Start with a blank text file. 2. Copy and paste this in: --- <?php session_start(); if (!isset($_SESSION['count'])) { $_SESSION['count']; } else { $_SESSION['count']++; } ?> Hello visitor, you have seen this page <?php echo $_SESSION['count'] ?> times.<p> To continue, <A HREF="<?php echo $_SERVER['PHP_SELF']; ?>">click here</A> --- 3. Open it up in your browser, and test that it works (the value of $_SESSION['count'] should increase with each click) 4. If that much works, open up the URL in a second window, and try to run two separate sessions... (the first window might be on 10 clicks, and the new one will be starting from 1) 5. If we're still cool, now try it without cookies maybe, by adding the SID to the URL that they click on. If all this works, then the problem is obviously in your code somewhere, not an issue with PHP/sessions/browsers/cookies/etc. Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php