summaryrefslogtreecommitdiffstats
path: root/regenerateSessionId.php
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-06-08 11:55:02 +0200
committerRemi Collet <remi@remirepo.net>2018-06-08 11:55:02 +0200
commitb6c457247052c36a60c4d3b53c2256db22a8a62c (patch)
treed78eb45784a9c3c3b2d6d13e9fe9f1b887456188 /regenerateSessionId.php
parenta4b4a23c74418534d48cee41123c93277cb08155 (diff)
update to 4.0.2
open https://github.com/phpredis/phpredis/pull/1365 use PHP_BINARY instead of php and allow override report https://github.com/phpredis/phpredis/issues/1364 missing files in pecl archive add new redis.session.lock* options in provided configuration
Diffstat (limited to 'regenerateSessionId.php')
-rw-r--r--regenerateSessionId.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/regenerateSessionId.php b/regenerateSessionId.php
new file mode 100644
index 0000000..f0e4c4e
--- /dev/null
+++ b/regenerateSessionId.php
@@ -0,0 +1,84 @@
+<?php
+error_reporting(E_ERROR | E_WARNING);
+
+$redisHost = $argv[1];
+$saveHandler = $argv[2];
+$sessionId = $argv[3];
+$locking = !!$argv[4];
+$destroyPrevious = !!$argv[5];
+$sessionProxy = !!$argv[6];
+
+if (empty($redisHost)) {
+ $redisHost = 'tcp://localhost:6379';
+}
+
+ini_set('session.save_handler', $saveHandler);
+ini_set('session.save_path', $redisHost);
+
+if ($locking) {
+ ini_set('redis.session.locking_enabled', true);
+}
+
+if (interface_exists('SessionHandlerInterface')) {
+ class TestHandler implements SessionHandlerInterface
+ {
+ /**
+ * @var SessionHandler
+ */
+ private $handler;
+
+ public function __construct()
+ {
+ $this->handler = new SessionHandler();
+ }
+
+ public function close()
+ {
+ return $this->handler->close();
+ }
+
+ public function destroy($session_id)
+ {
+ return $this->handler->destroy($session_id);
+ }
+
+ public function gc($maxlifetime)
+ {
+ return $this->handler->gc($maxlifetime);
+ }
+
+ public function open($save_path, $name)
+ {
+ return $this->handler->open($save_path, $name);
+ }
+
+ public function read($session_id)
+ {
+ return $this->handler->read($session_id);
+ }
+
+ public function write($session_id, $session_data)
+ {
+ return $this->handler->write($session_id, $session_data);
+ }
+ }
+}
+
+if ($sessionProxy) {
+ $handler = new TestHandler();
+ session_set_save_handler($handler);
+}
+
+session_id($sessionId);
+if (!session_start()) {
+ $result = "FAILED: session_start()";
+}
+elseif (!session_regenerate_id($destroyPrevious)) {
+ $result = "FAILED: session_regenerate_id()";
+}
+else {
+ $result = session_id();
+}
+session_write_close();
+echo $result;
+