刷新页面时显示上一个会话变量

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 am 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.