开发者

Displaying the last session variable when refreshing the page

I usually have problems with sessions.

My problem is that: If I have a have a session variable that stores the typed email address

$_SESSION['email']=$_POST['myemail'];

and then I want my page to display the entered email in the welcome page when the user clicks on login

echo '".$_SESSION['email']."';

my code works fine but when user2 logged in and user1 refreshed the page, the page displays Welcome user2 because the last session variable stores user2's email.

I a开发者_如何学Gom so sorry for this easy question but I am still learning PHP.


IF both users are on the same browser, at the same time (for some as for yet unseen reason), and IF they are not using different sessions, the session variable will get reused and overwritten.


You have to unset() the SESSION or destroy the session, like this:

session_start();
session_destroy();


Sessions are tied to a specific browser by the PHPSESSID cookie sent with each request. The only way one user's session could affect another is if both users are using the same physical computer.

I don't think you're having the problem you think you're having.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜