1

I've uploaded my custom PHP website on Hostgator server. My problem is system automatically destroy session and logout after few minutes if no movement on screen.

I've tried by putting gc_maxlifetime and gc_maxlifetime in header but not working. is there any other solution? I would appreciate any ideas.

<?php 
ob_start();
error_reporting(0);
session_start();

ini_set(session.cookie_lifetime, 86400);
ini_set(session.gc_maxlifetime, 86400);

header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
.
.
.  
?>
Dev Miro
  • 39
  • 8
  • Possible duplicate of [How to set lifetime of session](https://stackoverflow.com/questions/6360093/how-to-set-lifetime-of-session) – Shanu k k Jun 13 '17 at 11:51

1 Answers1

2

Set it before session_start(); :

<?php 
ob_start();
error_reporting(0);
ini_set(session.cookie_lifetime, 86400);
ini_set(session.gc_maxlifetime, 86400);
session_start();

http://php.net/manual/en/function.session-set-cookie-params.php

Ahmed Ginani
  • 6,522
  • 2
  • 15
  • 33