how to set session timeout in php.ini file? – PHP

  php

Q(Question):

in php.ini file…


session.gc_maxlifetime = 1440

if i change the value it doesnt work… i set the


session.gc_maxlifetime = 3600

but it doesnt work…
how to set session timeout to one hour?
plz help…

A(Answer):

// php.ini setting required for session timeout.

ini_set(‘session.gc_maxlifetime’,60*60);
ini_set(‘session.gc_probability’,1);
ini_set(‘session.gc_divisor’,1);

u can use ini_get function to see if your changes has been saved.

hope this helps.

A(Answer):

// php.ini setting required for session timeout.

ini_set(‘session.gc_maxlifetime’,60*60);
ini_set(‘session.gc_probability’,1);
ini_set(‘session.gc_divisor’,1);

u can use ini_get function to see if your changes has been saved.

hope this helps.

A(Answer):

where i put this in my php code or in php.ini file?

A(Answer):

if u have access to php.ini file, search the for

session.gc_maxlifetime
session.gc_probability
session.gc_divisor

and set there values as mentioned in the functions

other thing i’ve remembered may be the line are comments. remove # before the line

A(Answer):

i want to set session time out 5 mint….
how to change
ini_set(‘session.gc_maxlifetime’,60*60);
ini_set(‘session.gc_probability’,1);
ini_set(‘session.gc_divisor’,1);

according to my need

A(Answer):

ini_set(‘session.gc_maxlifetime’,60*5);
for 5 minutes.

value is in seconds. you can also give like this,
ini_set(‘session.gc_maxlifetime’,300);

Note: Restart Apache once done the modification. Then only it will reflect.

LEAVE A COMMENT