Skip to content

Instantly share code, notes, and snippets.

@lonalore
Created June 18, 2018 11:59
Show Gist options
  • Save lonalore/e2da5dc08b3779bb8c91cf5eee9cd905 to your computer and use it in GitHub Desktop.
Save lonalore/e2da5dc08b3779bb8c91cf5eee9cd905 to your computer and use it in GitHub Desktop.
<?php
/**
* Some distributions of Linux (most notably Debian) ship their PHP
* installations with garbage collection (gc) disabled. This depends on
* PHP's garbage collection for clearing sessions, ensure that garbage
* collection occurs by using the most common settings.
*/
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);
/**
* Set session lifetime (in seconds), i.e. the time from the user's last visit
* to the active session may be deleted by the session garbage collector. When
* a session is deleted, authenticated users are logged out, and the contents
* of the user's $_SESSION variable is discarded.
*/
ini_set('session.gc_maxlifetime', 200000);
/**
* Set session cookie lifetime (in seconds), i.e. the time from the session is
* created to the cookie expires, i.e. when the browser is expected to discard
* the cookie. The value 0 means "until the browser is closed".
*/
ini_set('session.cookie_lifetime', 2000000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment