Advertisement:

Author Topic: Osclass - Increase session time for logged in user  (Read 713 times)

jaysukh

  • Newbie
  • *
  • Posts: 3
Osclass - Increase session time for logged in user
« on: October 07, 2016, 04:34:42 pm »
Hello

Currently i face problem, I am automatic logout after some time.

I want to increase time to session/cookie expiration, user should be logged in till they click on logout button.

Any one suggest me some ideas...

thanks

jaysukh

  • Newbie
  • *
  • Posts: 3
Re: Osclass - Increase session time for logged in user
« Reply #1 on: November 03, 2016, 09:33:05 am »
Hello

I get solution by set default remember 1  ;)

if ( Params::getParam('remember') == 1 ) {
   //this include contains de osc_genRandomPassword function
   require_once osc_lib_path() . 'osclass/helpers/hSecurity.php';
   $secret = osc_genRandomPassword();

   User::newInstance()->update(
      array('s_secret' => $secret)
      ,array('pk_i_id' => $user['pk_i_id'])
   );

   Cookie::newInstance()->set_expires( osc_time_cookie() );
   Cookie::newInstance()->push('oc_userId', $user['pk_i_id']);
   Cookie::newInstance()->push('oc_userSecret', $secret);
   Cookie::newInstance()->set();
}

Seems its working fine..

serjuc11111

  • Hero Member
  • *****
  • Posts: 814
Re: Osclass - Increase session time for logged in user
« Reply #2 on: November 06, 2016, 02:11:19 pm »
ini_set('session.gc_maxlifetime', 3600);//1 hour
session_set_cookie_params(3600);
session_start();

increase the number 3600 for your need