By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,049 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,049 IT Pros & Developers. It's quick & easy.

how to delete session automatically after ther the time expires

P: n/a
hi frnds,

In my page, for every user login, it will create a session
file for them with thier name itself in the default session folder, Now
i want to do is, If a person is use idle for 10 minutes, automatically
his respective session file should be deleted. How is should be, plz
tell me some idea or give some sample code

Thanks
Dinesh...

Jan 17 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ba*****************@gmail.com wrote:
hi frnds,

In my page, for every user login, it will create a session
file for them with thier name itself in the default session folder, Now
i want to do is, If a person is use idle for 10 minutes, automatically
his respective session file should be deleted. How is should be, plz
tell me some idea or give some sample code

Thanks
Dinesh...
Hi,

Simply make the sessiontime-out 10 minutes.
You can set this in php.ini, or if php.ini is out of reach: set it manually
via ini_set.

Look for session.cookie_lifetime

About the deleting: You probably should not worry about that.
PHP will delete them itself.
How is this handled?
Each request to PHP, PHP will generate a random number and compare that to
what you defined in php.ini under:
- session.gc_probability
- session.gc_divisor

In my example, 1 in thousand times PHP will delete all old sessionfiles.
More explanation is given in php.ini and on www.php.net.

Regards,
Erwin Moller
Jan 17 '07 #2

P: n/a
Erwin Moller wrote:
ba*****************@gmail.com wrote:
>hi frnds,

In my page, for every user login, it will create a session
file for them with thier name itself in the default session folder, Now
i want to do is, If a person is use idle for 10 minutes, automatically
his respective session file should be deleted. How is should be, plz
tell me some idea or give some sample code

Thanks
Dinesh...

Hi,

Simply make the sessiontime-out 10 minutes.
You can set this in php.ini, or if php.ini is out of reach: set it
manually via ini_set.

Look for session.cookie_lifetime

About the deleting: You probably should not worry about that.
PHP will delete them itself.
How is this handled?
Each request to PHP, PHP will generate a random number and compare that to
what you defined in php.ini under:
- session.gc_probability
- session.gc_divisor
Forgot the example. :P

session.gc_probability = 1
session.gc_divisor = 1000

>
In my example, 1 in thousand times PHP will delete all old sessionfiles.
More explanation is given in php.ini and on www.php.net.

Regards,
Erwin Moller
Jan 17 '07 #3

P: n/a
hi Erwin

I have change the session_lifetime in php.ini file which you
have said. But still the session files remains same, Another thing i
have noticed is, If give value as 5, then only two file are present in
the session folder and if i give the value as 30, some 10 or 15 file
are present in the session folder.at the sametime after the time
reached which as fixed as value for session lifetime, nothing is
happening, everythings remains same i.e, no session file are getting
deleted.

Rgrds
Dinesh...

Jan 17 '07 #4

P: n/a
ba*****************@gmail.com wrote:
hi Erwin

I have change the session_lifetime in php.ini file which you
have said. But still the session files remains same, Another thing i
have noticed is, If give value as 5, then only two file are present in
the session folder and if i give the value as 30, some 10 or 15 file
are present in the session folder.at the sametime after the time
reached which as fixed as value for session lifetime, nothing is
happening, everythings remains same i.e, no session file are getting
deleted.

Rgrds
Dinesh...
Hi,

It is perfectly possible you have 30 old sessionfiles in your directory.
When using the settings in my example for gc.* they will only be garbage
collected once in thousand times.

Regards,
Erwin Moller
Jan 17 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.