0

Hi All,

Terminate session on closing the browser/tab. I am designing a site for the internal use of company employees at the client place, which contains some important secured data. Whenever a user logs in, modifies the data and they directly close the browser instead of logout. so the session is not killed as i set the session maximum time as 8 hours which is equivalent to 28800.
session_set_cookie_params('28800');
I am struck with this since last 2 days. I tried many ways after spending a day browsing all forums. But none of them helped me. It would be ok even if it works only in internet explorer.

Please help me as this urgent..

2
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by help_lucky
0

Is there an absolute need for the cookie? Getting rid of the cookie would clear up that problem.

0

Ok not any particular need for the cookie. But to clear that cookie how can i find/capture that the browser is closed. Is there any way to find that the window is closed. please do let me know if you know any.
Thanku

Is there an absolute need for the cookie? Getting rid of the cookie would clear up that problem.

0

Not sure about that. Your script would obviously terminate once the browser or tab is closed so how would it know that it was closed? Skipping the cookie and setting your session variables upon login would seem to be the way to go ... the session is destroyed when the user closes the browser.

I use cookies if I want to "remember" the user when they return or sometimes to auto login a user to chat rooms, forums, etc.

0

OK Thanku for the reply. I am quite new to php so please be a little patient with my small questions. I tried the following code to set the session variables in ini file.

//Set the ini params
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL ^ E_NOTICE);
ini_set('session.gc_maxlifetime', 10);
ini_set("session.gc_divisor", "1");
ini_set("session.gc_probability", "100");

Even though i set these params. My session is not getting terminated after 10 seconds. So i tried the statement session_set_cookie_params('28800');. On using this it is remembering the session varibales. Even though i close the window, without login credentials user is able to access the site. Once i comment this i am not able to set the maximum life time. with gc_maxlifetime. So please do help me.

Thanku in andvance!

Not sure about that. Your script would obviously terminate once the browser or tab is closed so how would it know that it was closed? Skipping the cookie and setting your session variables upon login would seem to be the way to go ... the session is destroyed when the user closes the browser.

I use cookies if I want to "remember" the user when they return or sometimes to auto login a user to chat rooms, forums, etc.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.