session Max life time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

session Max life time

Post by vinoth »

Hi
Now I am working with Sessions..
I have some doubt regarding that..

What is the max time we assign for session?

Is their any restriction or not..?

Please provide guidelines & suggestion regarding this.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

As much as you wish.
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Finding Defaults

Post by EricS »

Running the phpinfo() function will show you what your current session life time is. Remember, it's measured in seconds.

Code: Select all

phpinfo();
You can then adjust it using

1) ini_set()
2) a php directive in .htaccess
3) in your httpd.conf file
4) in the php.ini itself.

Which one you use depends on your needs and/or your permissions.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

ya

Currently i am using
ini_set() for set the session life time..

Which one is the best I can use ? Or everything works for same..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ini_set() is quite temporal and doesn't truely affect PHP's internal processes much in this regard.

It's often suggested to do it yourself artificially by storing a timestamp in the session so your code knows when to destroy it rather than hoping PHP will (since it's a triggered event.)
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

hi all

Sorry for late reply..

I set the session Maxlife time as one hour but the client was not satisfied with that.

He does not want an Auto logout.. it should logout after the user clikck the logout button.

Is there any possible way to do that..
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

How many clients will you have?
There are 10 types of people in this world, those who understand binary and those who don't
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

hi Viadsun

one client only make so many changes on daily updations..

Is it any possible way to solve this problem
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Post by vinoth »

Is there any way to prevent session logout until the browser was closed
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Set the life time our a long time.. maybe a month or five. Make sure the cookie is a session cookie (the expiry time is zero in session cookies.)

It's easier to control if you shift the handling out of PHP's direct, autonomous control like to a database.
Post Reply