Cookie过期时间无效

时间:2018-08-16 07:26:24

标签: laravel cookies

我的1台计算机有问题,因此我将项目复制到另一台计算机(Windows,但该项目是在Linux上创建的),并且出现了问题。我有一些错误。首先就像标题一样

  

cookie过期时间无效。   我看到当我访问该控制器时

if($lang == 'pl' || $lang == 'en'){
        $this->checkLanguage($lang);
        $route = $lang . '.articles';
        return redirect()->route($route);
    } else {
        Session::flash('error', 'This language is\'t available');
        return redirect()->back();
    }

当我浏览文章时,我可以看到

  

由于目标计算机主动拒绝连接,因此无法建立连接。 (SQL:从stats(其中token为null的情况下,选择count(*)作为聚合)

我想第二个问题是在MySQL中保存访问者的方法。

$token = time() . rand(1, 999);
    if(!Cookie::get('visitors')){
        Cookie::queue(Cookie::make('visitors', $token), true, 1440);
    }
    $stats = stats::where('token', Cookie::get('visitors'))->count();
    if(Cookie::get('lang')){
        $lang = Cookie::get('lang');
    } else {
        $lang = 'en';
    }
    if($stats == 0){
        stats::create([
            'token' => $token,
            'lang' => $lang
        ]);
    }
    return $next($request);

你能帮我吗?有什么问题吗?

2 个答案:

答案 0 :(得分:0)

似乎是php 32位问题,check this out

编辑:我解决了这个问题,我在Goutte的github回购问题部分中评论了fix

答案 1 :(得分:0)

检查.env文件中的 SESSION_LIFETIME ,将该字段留空,以解决我的问题

相关问题