时间:2021-07-01 10:21:17 帮助过:11人阅读
session()->put("key","values") 没有设置成功,最后翻源码发现是使用文件缓存时候需要使用save() 方法才能持久化到数据库中。源码:vendor/laravel/framework/src/Illuminate/Session/Store.php
/**
* Save the session data to storage.
*
* @return bool
*/
public function save()
{
$this->ageFlashData();
$this->handler->write($this->getId(), $this->prepareForStorage(
serialize($this->attributes)
));
$this->started = false;
}由于使用文件缓存 因此write方法调用的源码:vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php
/**
* {@inheritdoc}
*/
public function write($sessionId, $data)
{
$this->files->put($this->path.'/'.$sessionId, $data, true);
return true;
}相关推荐:
Laravel 5.4 session 生效问题
php session会话如何写入redis
PHP的session反序列化漏洞详解
以上就是Laravel 5.4.36中session没有保存成功怎么办的详细内容,更多请关注Gxl网其它相关文章!