diff options
Diffstat (limited to 'include/session.php')
-rw-r--r-- | include/session.php | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/include/session.php b/include/session.php index 6c32e299f..6072bdb33 100644 --- a/include/session.php +++ b/include/session.php @@ -1,4 +1,4 @@ -<?php +<?php /** @file */ // Session management functions. These provide database storage of PHP // session info. @@ -6,12 +6,23 @@ $session_exists = 0; $session_expire = 180000; -if(! function_exists('ref_session_open')) { + + + +function new_cookie($time) { + $old_sid = session_id(); + session_set_cookie_params("$time"); + session_regenerate_id(false); + + q("UPDATE session SET sid = '%s' WHERE sid = '%s'", dbesc(session_id()), dbesc($old_sid)); +} + + function ref_session_open ($s,$n) { return true; -}} +} + -if(! function_exists('ref_session_read')) { function ref_session_read ($id) { global $session_exists; if(x($id)) @@ -21,9 +32,9 @@ function ref_session_read ($id) { return $r[0]['data']; } return ''; -}} +} + -if(! function_exists('ref_session_write')) { function ref_session_write ($id,$data) { global $session_exists, $session_expire; if(! $id || ! $data) { @@ -44,25 +55,25 @@ function ref_session_write ($id,$data) { dbesc($id), dbesc($default_expire), dbesc($data)); return true; -}} +} + -if(! function_exists('ref_session_close')) { function ref_session_close() { return true; -}} +} + -if(! function_exists('ref_session_destroy')) { function ref_session_destroy ($id) { q("DELETE FROM `session` WHERE `sid` = '%s'", dbesc($id)); return true; -}} +} + -if(! function_exists('ref_session_gc')) { function ref_session_gc($expire) { - q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time())); - q("OPTIMIZE TABLE `sess_data`"); + q("DELETE FROM session WHERE expire < %d", dbesc(time())); + q("OPTIMIZE TABLE session"); return true; -}} +} $gc_probability = 50; @@ -71,6 +82,4 @@ ini_set('session.use_only_cookies', 1); ini_set('session.cookie_httponly', 1); -session_set_save_handler ('ref_session_open', 'ref_session_close', - 'ref_session_read', 'ref_session_write', - 'ref_session_destroy', 'ref_session_gc'); +session_set_save_handler ('ref_session_open', 'ref_session_close', 'ref_session_read', 'ref_session_write', 'ref_session_destroy', 'ref_session_gc'); |