-2

I have made a site with a login system using PHP to start a logged in session with the id of the logged in user. I have a core.Inc.php file in which I Used session_start(); and when I proceed to login using that logged in session this session is set until destroyed by logging out. Now I have register.php (But this could be any php page) and I have set this page up in a way that if I go to that page but I'm already logged in it sends me back to index.php and it starts a session called alert_ar_loggedin. Then, in my index page i have an if statement saying that if this session is active (I check that with a funcion) I include this alert through another php. Now I want to destroy that session in a way that the next time I come to a page or I refresh it that the session is no longer active. I can't use session_destroy() Because that also destroys the logged in session. How should I do this? Or is there a better approach for such an alert?

2 Answers2

2

Try using this:

unset($_SESSION['your_session_variable_name']);
Idos
  • 15,053
  • 14
  • 60
  • 75
Herolind
  • 43
  • 5
0

Try like this,

unset($_SESSION['name']);
Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41