views:

104

answers:

2

I am working on a e-commerce project using the Auth Component for authentication and Sessions Component for storing my cart.

The problem is that the session gets cleared abruptly after a while even when I am actively browsing the site. I know this should be because of the Session timeout but just increasing the timeout value is not the solution I am looking for.

I want the session to expire only when a user closes his browser. Can this be achieved?

A: 

AFAIK all you can do is to set a session timeout variable far into the future. Sessions are automatically cleared when the browser is closed (unless you set a Remember Me type cookie). Setting it far into the future will effectively accomplish what you need to do.

How long into your session is it timing out? It should only timeout when your user is inactive for a period of time. If it times out in-between requests, and you know the timeout time has not elapsed, you have some other issues going on. What are the settings in your core.php file regarding your security levels and session timeouts?

Travis Leleu
Hey, thanks for replying. I have set the Security.level to high and the Session.timeout is set to 120 secs. As per your suggestion I can set the timeout to a higher value but in that case the sessions are staying active even when I can close my browser and come back later. Anyways, I guess there is no way to determine if the browser was closed as its on the client side.
aadravid
Setting the security level to high has other implications beyond just multiplying the session timeout, IIRC. It adds referer checking when med|high. When set to high, it's regenerating the session ID between *every* request. I'd advise you to turn it to medium. Then when you close the browser (whole browser must exit, not just that tab... check your task manager to make sure it's gone) it'll close the session. And yes, you cannot determine if the browser was closed client side.
Travis Leleu
Ok, thanks... I have changed it to medium and things are working fine so far! :)
aadravid
ill keep my fingers crossed for ya!
Travis Leleu
A: 

Check your php.ini settings.

Leo

related questions