Simple session lifetime

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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Simple session lifetime

Post by aceconcepts »

Hi,

I know this question has been asked time and time again but i simply can't get my session's lifetime to go beyond the default of 24min.

Does anyone know a simple way of increasing or decreasin the session lifetime?

Thanks.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Simple session lifetime

Post by Sindarin »

have you tried changing the session.gc_maxlifetime value in php.ini?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Simple session lifetime

Post by aceconcepts »

i'm afraid i don't have access to php.ini.

However, would this change work?

Also, is there a way of setting the session lifetime based on a request? i.e. setting it by entering a value in a text box.

Thanks for your prompt response.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Re: Simple session lifetime

Post by vinoth »

Its possible to change the session.gc_maxlifetime

by ini_set('session.gc_maxlifetime', $garbage_timeout);. you have to set the timeout values in seconds

I think this will solve that problem.But I was not tested.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Simple session lifetime

Post by aceconcepts »

I will give this a go.

Thanks.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Simple session lifetime

Post by pickle »

Unfortunately, garbage collection of old sessions uses the value in php.ini, not whatever you set via ini_set(). The only way to change this value is by modifying php.ini.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
vinoth
Forum Contributor
Posts: 113
Joined: Thu Aug 02, 2007 3:08 am
Location: India
Contact:

Re: Simple session lifetime

Post by vinoth »

Any Possible way to modify the php.ini file through programming.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Simple session lifetime

Post by aceconcepts »

vinoth wrote:Any Possible way to modify the php.ini file through programming.
This was also part of my initial point.
Post Reply