Jump to content



Photo
- - - - -

Increase session timeout

session timeout increase osc oscommerce oscomm php mysql

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1   isumitg

isumitg
  • Members
  • 29 posts

Posted 28 May 2012 - 22:51

Whenever a user is logged into my website, he is automatically signed out after a fixed amount of time. How can I modify this time?

1. I want user to be logged out only when he clicks on "Logout" button. The time when he click the logout button might be 2 weeks, 1 month or longer.

2. I want user to keep logged in even if he closes the web-browser and reopens it. How can I do this?

Please help. Thanks.

#2   DunWeb

DunWeb

    The Censored One

  • Members
  • 13,084 posts

Posted 28 May 2012 - 23:45

@isumitg

Look for this code in the /includes/functions/sessions.php file


if (STORE_SESSIONS == 'mysql') {
if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
$SESS_LIFE = 1440;
}

Change the 1440 to whatever you want.....



Chris


ps. Closing the browser will end the session

Edited by DunWeb, 28 May 2012 - 23:46.

:|: Was this post helpful ? Click the LIKE THIS button :|:

See my Profile to learn more about add ons, templates, support plans and custom coding (click here)

#3   isumitg

isumitg
  • Members
  • 29 posts

Posted 20 June 2012 - 19:04

Thanks Chris @DunWeb

I changed as you suggested but it is not working. Any idea why?

I have changed it to the following

if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
	  $SESS_LIFE = 864000; //10 days
	}

Below are my settings in Admin panel:

Session Directory: <...>/public_html/catalog/includes/work/
Force Cookie Use: False
Check SSL Session ID: False
Check User Agent: False
Check IP Address: False
Prevent Spider Sessions: True
Recreate Session:True

Edited by isumitg, 20 June 2012 - 19:06.


#4   isumitg

isumitg
  • Members
  • 29 posts

Posted 30 June 2012 - 18:40

Hi Chris / Phil @DunWeb @MrPhil

Any suggestion on the above? Please help.

Thank you.

#5   chadcloman

chadcloman
  • Members
  • 291 posts

Posted 15 January 2013 - 18:20

Well, one obvious reason for that failing is if the default PHP session.gc_maxlifetime value is defined and is set to something other than zero (which will often be the case). The inner code will not be executed at all, and it doesn't matter what value you set it to.

So I suggest replacing these three lines of code:
if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
$SESS_LIFE = 1440;
}
with just the one line:
$SESS_LIFE = 864000; //10 days

Check out Chad's News.