Reputation: 750
I am setting a session during auth/register
(Laravel Signup Auth) functionality.
When I try to access the session
my_user_referral_session
I set during auth/register
in the method which is executed immediately after Signup.
I am getting following error
RuntimeException in Request.php line 870:
Session store not set on request.
My Routes.php file
Route::get("/dashboard","DashboardController@dashboard");
DashboardController.php
public function __construct() {
$this->middleware('auth');
}
public function dashboard() {
$request = new \Illuminate\Http\Request();
if($request->session()->has("my_user_referral_session")){
/* Reading session data set during Laravel auth/register
}
Note: When I use session()
helper method it works without any error, but I need to remove the session , which is not in session()
helper methods.
Notice: $this->middleware('auth'); in the construct. I suspect this is causing issue
Upvotes: 0
Views: 1482
Reputation: 249
I think the line
$request = new \Illuminate\Http\Request();
creates a new "empty" request, so there is no session data there.
The best way to get the session data there is to use the session() helper:
session('my_user_referral_session')
will return your required information or null if there is no session data with that key.
Upvotes: 0
Reputation: 3795
You can remove the session with session()->forget('my_user_referral_session');
Session is not bound to the request.
Upvotes: 1