Can you post the relevant controller and view code?
Here is my View code where i am checking that user has logged in or not.
<div class="ribbon">
<nav>
@if(Auth::check())
<ul class="profile-nav">
<li class="active"><a href="#" title="Dashboard">Hi, {{Auth::user()->name}}</a></li>
</ul>
<ul class="profile-nav">
<li class="active"><a href="/dashboard" title="Dashboard">Dashboard</a></li>
</ul>
<ul class="profile-nav">
<li class="active"><a href="/logout" title="Logout">Logout</a></li>
</ul>
@else
<ul><li class="active"><a href="#" title="Dashboard">Hi, Guest</a></li>
</ul>
<ul>
<li class="active"><a href="#" id="showlogin" title="Login">Login</a></li>
</ul>
<ul>
<li class="active"><a href="#" id="showreg" title="Settings">Register</a></li>
</ul>
@endif
</nav>
</div>
and here is my controller code where i log in user by accesspting request parameters. $username=e(Input::get('username')); $password=e(Input::get('password'));
$credentials=array(
'username'=>$username,
'password'=>$password
);
if(Auth::attempt($credentials))
{
$user=User::where('username','=',$username)->first();
Session::put('user',$user->name);
$res = array ("res"=>"success");
return Response::json($res, 200);
}
else
{
$res = array ("res"=>"fail");
return Response::json($res, 401);
}
in controller if i do Auth::check it returns true but in view it always returns false. also cookie is not persisting.
What if you pass the Auth data through to the view from the controller?
Actually session is not persisting. session data stores in filesystem but can's see session created in browser cookie as responce. no cookie is being created at all. even # laravel_session
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community