Connecting Tech Pros Worldwide Help | Site Map

how to delete session automatically after ther the time expires

balakrishnan.dinesh@gmail.com
Guest
 
Posts: n/a
#1: Jan 17 '07
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...

Erwin Moller
Guest
 
Posts: n/a
#2: Jan 17 '07

re: how to delete session automatically after ther the time expires


balakrishnan.dinesh@gmail.com wrote:
Quote:
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
Erwin Moller
Guest
 
Posts: n/a
#3: Jan 17 '07

re: how to delete session automatically after ther the time expires


Erwin Moller wrote:
Quote:
balakrishnan.dinesh@gmail.com wrote:
>
Quote:
>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

Quote:
>
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
balakrishnan.dinesh@gmail.com
Guest
 
Posts: n/a
#4: Jan 17 '07

re: how to delete session automatically after ther the time expires


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...

Erwin Moller
Guest
 
Posts: n/a
#5: Jan 17 '07

re: how to delete session automatically after ther the time expires


balakrishnan.dinesh@gmail.com wrote:
Quote:
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
Closed Thread