note 123892 added to class.sessionhandler
| From: | wei dot kavin at gmail dot com | Date: | Wed, 29 May 2019 07:38:55 +0000 |
| Subject: | note 123892 added to class.sessionhandler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211141@lists.php.net to get a copy of this message | ||
php -S localhost:8000 -t foo/
touch index.php
vi index.php
============================================================
class NativeSessionHandler extends \SessionHandler
{
public function __construct($savePath = null)
{
if (null === $savePath) {
$savePath = ini_get('session.save_path');
}
$baseDir = $savePath;
if ($count = substr_count($savePath, ';')) {
if ($count > 2) {
throw new \InvalidArgumentException(sprintf('Invalid argument $savePath
\'%s\'', $savePath));
}
// characters after last ';' are the path
$baseDir = ltrim(strrchr($savePath, ';'), ';');
}
if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true)
&& !is_dir($baseDir)) {
throw new \RuntimeException(sprintf('Session Storage was not able to create
directory "%s"', $baseDir));
}
ini_set('session.save_path', $savePath);
ini_set('session.save_handler', 'files');
}
}
$handler = new NativeSessionHandler("/var/www/foo");
session_set_save_handler($handler, true);
session_start();
$a = $handler->write("aaa","bbbb");var_dump($a);exit;
============================================================
outputï¼bool(false)
----
Server IP: 208.43.231.9
Probable Submitter: 119.81.81.244 (proxied: 36.33.24.70)
----
Manual Page -- http://php.net/manual/en/class.sessionhandler.php
Edit -- https://master.php.net/note/edit/123892
Del: integrated -- https://master.php.net/note/delete/123892/integrated
Del: useless -- https://master.php.net/note/delete/123892/useless
Del: bad code -- https://master.php.net/note/delete/123892/bad+code
Del: spam -- https://master.php.net/note/delete/123892/spam
Del: non-english -- https://master.php.net/note/delete/123892/non-english
Del: in docs -- https://master.php.net/note/delete/123892/in+docs
Del: other reasons-- https://master.php.net/note/delete/123892
Reject -- https://master.php.net/note/reject/123892
Search -- https://master.php.net/manage/user-notes.php