Skip to content

Instantly share code, notes, and snippets.

@sergiitk
Last active August 18, 2016 19:31
Show Gist options
  • Save sergiitk/016de7250f0041471840db5dc7e9f077 to your computer and use it in GitHub Desktop.
Save sergiitk/016de7250f0041471840db5dc7e9f077 to your computer and use it in GitHub Desktop.
<?php
// Persistent sessions.
session_name('your-name');
// Because your sessions in common folder could get collected by gc
// started by another script where this sessions aren't set.
ini_set("session.save_path", dirname(__FILE__) . '/tmp/');
// Decreases chance that gc process is started
// on every session initialization from 1% to 0.1%
ini_set("session.gc_divisor", 1000);
// Keep cookies and session files as long as possible.
ini_set("session.gc_maxlifetime", 2592000);
session_set_cookie_params(2592000);
session_cache_expire(2592000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment