Support the ongoing development of Laravel.io →
Session Views Testing
Last updated 1 year ago.
0
$personal_id = session('personal_id');
echo $personal_id;
0

still not show the session,

they said to add this in my route:

Route::group(['middleware' => 'web'], function () { Route::post('loginAction', 'LoginController@loginAction');

Route::get('profile', [
	'as' => 'profile',
	'uses' => 'UserController@getProfile'
]);

});

also not show anything and show the error: TokenMismatchException in VerifyCsrfToken.php line 67:>scosec said:

$personal_id = session('personal_id');
echo $personal_id;
0

token mismatch means you didn't set the csrf token in the login form

0

It solved thanks to alainbelez, how to solve it:

Route::group(['middleware' => 'web'], function () { Route::get('login', function () { return view('login'); });

Route::post('loginAction', 'LoginController@loginAction');

Route::get('profile', [
	'as' => 'profile',
	'uses' => 'UserController@getProfile'
]);

});

do not forget to add input type hidden token

<form class="form-grey-fields" method="POST" action="loginAction"> <input type="hidden" name="_token" value="{!! csrf_token() !!}"> <div class="form-group"> <label class="sr-only">Email</label> <input type="email" name="email" placeholder="Email" class="form-control">
					</div>
					<div class="form-group m-b-5">
						<label class="sr-only">Password</label>
						<input type="password" name="password" placeholder="Password" class="form-control">
					</div>
					<div class="form-group form-inline text-left m-b-10 ">

						<div class="checkbox">
							<label>
								<input type="checkbox"><small> Remember me</small>
							</label>
						</div>
						<a class="right" href="#"><small>Lost your Password?</small></a>
					</div>
					<div class="text-left form-group">
						<button class="btn btn-primary" type="submit">Login</button>

					</div>
				</form>

Thanks

0

Sign in to participate in this thread!

Eventy

Your banner here too?

newbievii newbievii Joined 6 Jan 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.