473,545 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

laravel session logout not working

107 New Member
I am using laravel inbuilt authentication but came across with the logout problem. Even after the logout i can go into dashboard. I tried flushing the session but it doesnt work. The middleware for the dashboard page is auth. Iam sure many have come across the cited bug .... kindly help me how to resolve it.

app/Http/routes.php

Expand|Select|Wrap|Line Numbers
  1. Route::get('/', 'Auth\AuthController@getLogin');
  2. Route::post('/', 'Auth\AuthController@postLogin');
  3.  
home controller
Expand|Select|Wrap|Line Numbers
  1. <?php namespace App\Http\Controllers;
  2. use App\Http\Controllers\Controller;
  3. use Illuminate\Contracts\Auth\Guard;
  4. use Illuminate\Contracts\Auth\Registrar;
  5. use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  6. use Illuminate\Support\Facades\Request;
  7. use Auth;
  8.  
  9. class HomeController extends Controller {
  10.  
  11.     /*
  12.     |--------------------------------------------------------------------------
  13.     | Home Controller
  14.     |--------------------------------------------------------------------------
  15.     |
  16.     | This controller renders your application's "dashboard" for users that
  17.     | are authenticated. Of course, you are free to change or remove the
  18.     | controller as you wish. It is just here to get your app started!
  19.     |
  20.     */
  21.  
  22.     /**
  23.      * Create a new controller instance.
  24.      *
  25.      * @return void
  26.      */
  27.     public function __construct()
  28.     {
  29.         $this->middleware('auth');
  30.     }
  31.  
  32.     /**
  33.      * Show the application dashboard to the user.
  34.      *
  35.      * @return Response
  36.      */
  37.     public function index()
  38.     {
  39.         return view('home');
  40.     }
  41.  
  42. }
  43.  
Illuminate/Foundation/Auth/AuthenticatesAn dRegistersUsers .php

Expand|Select|Wrap|Line Numbers
  1. /**
  2.      * Log the user out of the application.
  3.      *
  4.      * @return \Illuminate\Http\Response
  5.      */
  6.     public function getLogout()
  7.     {
  8.         //dd("Logging Out!!!");
  9.         $this->auth->logout();
  10.  
  11.         Session::flush();
  12.  
  13.         return redirect('/');
  14.     }
  15.  
Jul 20 '15 #1
0 7079

Sign in to post your reply or Sign up for a free account.

Similar topics

1
16552
by: mubarak basha | last post by:
hi friends, i have created session using login details successfully...now i have a doubt that is how can i logout the page....once i logout the page then that previous page cannot be appear.for that how can i write the code in logout.asp page......... here is my login.asp coding... <% Response.Expires = -1000 Response.Buffer...
4
1857
by: Parrot | last post by:
For some reason my Session state stopped working in my webpages. I cannot pass a variable from one webpage to another using the Session. For example: Web page 1: Session = dbname; Response.Redirect("Webpage2"); Webpage 2:
1
1253
by: tomb | last post by:
This is my first time using php and sessions. I am trying to follow what I recently read, but it isn't working as I was expecting. Please tell me what I'm doing wrong? I have defined my session handlers in a session handler include file, sessions.php. This file calls session_set_save_handler() and also calls session_start(). Each...
1
1572
by: mgn2683 | last post by:
I am working on a project using Dreamweaver CS3, and I am not very familiar with html or php code. Essentially I am trying to set something up so that a user is allowed to enter information into forms, but I would like to have a 3 hour session time. Does anyone know any code that would work? I tried: <?php // Prolong session...
7
3434
by: thesti | last post by:
hi, i'm learning and trying to develop a web with php. the logout script of mine seems not working since that after i pressed the logout link. i still get the greeting "welcome, 'username' ". this is the script in the logout.php that <html> <head> <meta http-equiv="refresh" content="1; URL=index.php">
4
1497
by: Ravigandha | last post by:
Hello everbody, My problem is.My code is working in localhost but not working when i upload it to website.In this case is it the problem with the hosting server or with php sessions as i have used. My code for logout page is <?php ob_start(); session_start(); session_unset(); $_SESSION= ""; $_SESSION= ""; $_SESSION= "";
6
5965
by: Thiago Macedo | last post by:
I could not find on the web a complete solution for this task. This is not the perfect solution, because it's doesn't have the ability to log the logout if browser crash or user leave it open while the session time out expires. So, any improvement would be apreciated. 1. Make the system frameable, by creating a frameset page with an...
0
1367
by: shinu bhaskar | last post by:
In my JSP program. example 3 page: login.html,login_validate.jsp,welcome.htm. My aim is if we type direct link of welcome.htm not show that page.for this purpose i used jsp session. its working some time some time not working why ? hep....
0
1395
by: Limay | last post by:
I have designed a WordPress site with an EStore plugin. Until a couple weeks ago, it was working great. Now when someone adds a product to the cart and hits the checkout button we get the following error: Either your shopping cart is empty or the PHP Session on your server is not working correctly. I have verified with the plugin author that...
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.