【发布时间】:2017-09-12 09:55:19
【问题描述】:
我在 laravel 中的会话有问题, 在 localhost 中工作正常,但在共享主机 (webhostingworld) 中不起作用 相同的代码。 这是 session.php 中的代码
<?php
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'store' => null,
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => '',
'secure' => env('SESSION_SECURE_COOKIE', false),
'http_only' => true,
];
这是web.php中的代码
Route::get('/put',function(){
Session::put('test','testing');
return Session::get('test'); //here returning testing
});
Route::get('/get',function(){
return Session::get('test'); //but here return empty result
});
服务器 PHP 版本 5.6.31,无法通过 SSH 访问共享主机
【问题讨论】:
-
检查
storage的权限,如果你使用的是linux:chmod -R a+rw storage/ -
存储权限 777 @Troyer
-
你的存储目录有文件吗?
-
有app、framework、logs文件夹@DanMiller
-
对不起。我的意思是在会话存储路径中。
framework/sessions