php - Page brings back old session after session_destroy -


No clue why this is doing but my logout.php code works fine and redirects to home page and Session is destroyed. When I go back to a certain page, it brings an old session that I do not get.

That's my login file

  $ _SESSION ['id'] = $ line ['user_id']; $ _SESSION ['username'] = $ line ['username']; Setcookie ('id', $ line ['user_id'], time () + (60 * 60 * 24 * 2)); Setkey ('Username', $ line ['username']], time () + (60 * 60 * 24 * 2));   

Here is my logout file

  // If the user is logged in, remove session to logout them session_start (); If (isset ($ _ session ['id'])) {$ _SESSION = array (); // if user (ADAT ($ _COOKIE [session_name ())) {setcookie ('session_name ()', '', time () - an hour ago (3600) by establishing its end to user id and user name Remove 3600); } // session session_unset () deleted; Session_destroy (); } // Delete user id and username password set cookies ('id', '', time () - 3600); Setkey ('user name', '', time () - 3600); Not set ($ _cookie ['id']); Not set ($ _cookie ['username']); Not set ($ _ session ['id']); Not set ($ _ session ['username']); // redirect home page $ home_url = 'http://page.com/'; Header ('location:' $ Home_url); Go out();   

I have a code on my page:

session_start ();

  // If session sessions are not set, try setting them with a cookie (! ($ _ Session ['id']) () (if (($ ($ $ $ _COOKIE ['id']) & amp; Continue ($ _COOKIE ['username']) {$ _SESSION ['id'] = $ _COOKIE ['id']; $ _SESSION ['username'] ] = $ _COOKIE ['username'];}}   

This code works fine on home page, but when I come to a sub directory it brings a random old session .

<

  unset ($ _ [[session] [*] ] Do not set ($ _ session ['username']);   

Then your session_destroy () Call the function.

In addition to this, I also read somewhere (can not remember where, unfortunately - maybe even ...) that it can directly result in a SQL result ($ Row ['id']) In a cookie it is best to first store the result in $ _SESSION, then store $ _SESSION in the cookie.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -