473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to delete session automatically after ther the time expires

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
4 4145
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
2
by: prakash | last post by:
Hi All Can anyone explain the difference between Response.Expires & Session.Timeout Regards Prakash
12
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
5
by: Snig | last post by:
Hi guys How can I make the session in an ASP.NET application so that it NEVER EXPIRES ? thanks
6
by: spacehopper_man | last post by:
I'm considering ditching all use of Session state in favour of Application state. This is because - from what I can work out - it will be more memory efficient for me. I have three questions:...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
2
by: Athenian | last post by:
Hi guys. Currently I need a javascript (client side) or vbscript(server side) code to check automatically for session expiration and force the redirection to a message page or the log-in page....
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
4
by: rgparkins | last post by:
Hello I am running out of time with a problem I have running PHP 5.04 and Apache 2.0 and really need help :(. I have a page that stores a variable in session but each time I reload that page the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.