aboutsummaryrefslogtreecommitdiffstats
path: root/include/session.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/session.php')
-rw-r--r--include/session.php58
1 files changed, 40 insertions, 18 deletions
diff --git a/include/session.php b/include/session.php
index 6c32e299f..b531688e2 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,36 @@
$session_exists = 0;
$session_expire = 180000;
-if(! function_exists('ref_session_open')) {
+
+
+
+function new_cookie($time) {
+ $old_sid = session_id();
+
+// ??? This shouldn't have any effect if called after session_start()
+// We probably need to set the session expiration and change the PHPSESSID cookie.
+
+ session_set_cookie_params($time);
+ session_regenerate_id(false);
+
+ q("UPDATE session SET sid = '%s' WHERE sid = '%s'", dbesc(session_id()), dbesc($old_sid));
+
+ if (x($_COOKIE, 'jsAvailable')) {
+ if ($time) {
+ $expires = time() + $time;
+ } else {
+ $expires = 0;
+ }
+ setcookie('jsAvailable', $_COOKIE['jsAvailable'], $expires);
+ }
+}
+
+
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 +45,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 +68,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 +95,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');