Wednesday, October 17, 2012

PHP session timeout cookie lifetime


There are many ways to set cookie based session timeout in PHP. You can edit your php.ini or put it in .htaccess but I choose for today this piece of code:

<?php
ini_set('session.gc_maxlifetime', 172800);
ini_set('session.cookie_lifetime', 172800);
session_start();
?>

The session above will be valid for 2 days.