I need to destroy session after page closed in browser. i tried to unset $_session['value']; but it can not working it destroy current page but i need destroy after closed in browser
Asked
Active
Viewed 2,264 times
0
-
does this help? http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – atoms Jul 06 '16 at 10:47
-
no it does not work for me i need destroy session after page closed in browser not some minutes.. – Jul 06 '16 at 10:50
-
1You could listen to the event `unload` and asynchronously call a php page which then destroys the session. But I think every professional php/js-developer will hate me for that idea... – Jul 06 '16 at 10:53
1 Answers
-1
You can write this
session_set_cookie_params(0);
session_start();
This will destroy session when the browser is closed.

Jahid Mahmud
- 1,136
- 1
- 12
- 32
-
-
-
May be you can find the answer here http://stackoverflow.com/questions/3177364/destroy-php-session-on-page-leaving. hopefully this might help you – Jahid Mahmud Jul 06 '16 at 11:13