samved Posted May 7, 2011 Share Posted May 7, 2011 Hi, I am facing problems in destroying the session variables in my logout file :'( .I have used session_id() in my php files for ex $sid = session_id().Now when I click on logout I naviagte to my index file but the session variable $sid still remain.I have chkd it.I have kept session_start() function in a file and I am including that file in every php by require_once function.The file is palced in Includes folder..is it causing the problem?? Plz help me out Also can I use session_start() more than once in a single php file? My logout file is : <?php session_start(); session_destroy(); header("location:index.php"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/235764-destroying-session-variables/ Share on other sites More sharing options...
wildteen88 Posted May 7, 2011 Share Posted May 7, 2011 session_destroy() only erases the data stored within the current active session. If you want a new session id to be generated when the user logs out you'll need to use session_regenerate_id. Quote Link to comment https://forums.phpfreaks.com/topic/235764-destroying-session-variables/#findComment-1211894 Share on other sites More sharing options...
samved Posted May 7, 2011 Author Share Posted May 7, 2011 Thanks a lot for your reply, the solution worked for me.Is there any way I can destroy old session Id instead of regenerating it? Quote Link to comment https://forums.phpfreaks.com/topic/235764-destroying-session-variables/#findComment-1211918 Share on other sites More sharing options...
wildteen88 Posted May 7, 2011 Share Posted May 7, 2011 What are you wanting to with the session id when your destroy the session. The id will never be unset, session_id will always return the id of the current active session, even after calling session_destroy. Quote Link to comment https://forums.phpfreaks.com/topic/235764-destroying-session-variables/#findComment-1211923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.