how to remove sessions in Laravel 5
You should use this method
Route::get('/logout', function() {
Session::forget('key');
if(!Session::has('key'))
{
return "signout";
}
});
You can try with Session::pull('key');
And if you want to delete all sessions variable you can use Session::flush();
http://laravel.com/docs/5.0/session#session-usage
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class StudentRecord extends Controller
{
public function logout(Request $req)
{
if($req-session()->has('key'){
$req->session()->forget('key');
return redirect('/');
}
//Or simple
public function logout(Request $req)
{
//if($req-session()->has('key')
$req->session()->flush();
}
}
//Then Do this in your route file
Route:get("/logout",StudentRecord@logout);
<a href=" {{ url(logout)}}">logout</a>