dongpeihui1051 2016-06-20 05:28
浏览 277

Laravel Auth ::尝试正在运行,但auth :: user()变为NULL

I am new in Laravel.

Now I want to use the middleware.

So Please help me.

My code is:

    $input = Input::except('_token');

    if(Auth::attempt($input)){         
        return redirect()->intended('dashboard');
    }else{
        return Redirect::to(route('login'))
                ->with('message','Sorry, Wrong Username and password .');
    }

The Auth::attempt is working perfectly and its redirecting to dashboard as expected.

But when I try to check the Auth::check function from the controller its returning the else statement.

public function dashboard(){      
    if(Auth::check()){
      return View::make('dashboard');
    }else{
      return "Not logged in";
    }
}

How can I fix the issue ?

Session.php

'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
'http_only' => true,
  • 写回答

2条回答 默认 最新

  • dongshen9686 2016-06-20 05:33
    关注

    If you are using subdomain then change this line below (config/session)

    'domain' => null,
    to
    
    'domain' => '.yourdomain.com',
    

    Also if you are using files to store session

    'driver' => env('SESSION_DRIVER', 'file'),
    

    then check if you have write permission given to storage/framework/sessions directory . you also can try changing database sessions .

    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭