From 115d57542186faf65860b12256f32e4d334b805f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 29 Sep 2016 12:20:43 +0200 Subject: [PATCH] Add convenient method to create new session records --- program/lib/Roundcube/rcube_session.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/program/lib/Roundcube/rcube_session.php b/program/lib/Roundcube/rcube_session.php index f0c012cbf..9fc564fac 100644 --- a/program/lib/Roundcube/rcube_session.php +++ b/program/lib/Roundcube/rcube_session.php @@ -179,6 +179,24 @@ abstract class rcube_session $this->gc_shutdown(); } + /** + * Creates a new (separate) session + * + * @param array Session data + * + * @return string Session identifier (on success) + */ + public function create($data) + { + $length = strlen(session_id()); + $key = rcube_utils::random_bytes($length); + + // create new session + if ($this->write($key, $this->serialize($data))) { + return $key; + } + } + /** * Merge vars with old vars and apply unsets */