Forum Moderators: coopster
I am making a website in which i am facing the Session Expiration Problem, i mean, after a certain time interval the session is expired and i have to login again. is there anyway to keep the session alive untill and unless the user closes the browser window himself?
currently i am using php 4.1.1 and functions like
session_start(), session_register() i found two functions in manual
session.cookie_lifetime session.cache_expire
but i am not sure if i can use them to fix my problem.
please help me to solve this.
thanks in advance
First, you need to configure those garbage collection directives. If you don't set that up correctly, the server is going to do it's job, just as you are telling it to, and clean out any sessions based on those directives. It is not going to care one bit about the user's cookie setting. Old session is old session, period.
That brings us to the other side of any session, the client. You need to set the session cookie so that it expires only when the user closes the browser (assuming you are using session cookies). The session.cookie_lifetime [php.net] directive helps you set that up.
i think its garbage collection which is doing the harm. please tell me exactly how to disable grabage collection so that it doesnt affect sessions keeping in mind that i am not working on my local pc but online server.
thanks in advance
ini_set("session.gc_maxlifetime","seconds"); by default it has 1440 value, but i am not able to set it in php.ini as when i execute this script on my pc then i check it in php.ini but it remains the same as 1440. I think if i can do it with online installation too with ini_set, because it will make changes related to my script life time i.e when my script will be terminated the changes will be redone.
any idea why it is not writing the value i mention in ini_set function above?
Sets the value of the given configuration option. Returns the old value on success, FALSE on failure. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.