My web application has a strange/weird behaviour. Whenever i log-in into the apps, everything fine. After click few times menu, it gets logout. My apps is running well without any weird that behaviour in development local.
Route::group(['middleware' => 'auth'], function () {
Route::group(['prefix' => 'app','as' => 'app.'],function(){
......
i use default auth middleware from laravel. i also change session driver from file to database but still have a problem with that weird behaviour of logout. My applications used to put in the shared hosting, and right now moved into the cloud. I have no issue before in shared hosting. But after moving into the cloud this is what happens.
note: i also have try change the cookies name but still got nothing.
here is the config session file
<?php
use Illuminate\Support\Str;
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => env('SESSION_CONNECTION', null),
'table' => 'sessions',
'store' => env('SESSION_STORE', null),
'lottery' => [2, 100],
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE'),
'http_only' => true,
'same_site' => 'lax',
];
Related
When i login into my Laravel application and dont click the checkbox "Remember me" then i will get kicked out of my session everytime when i try to make a api request but i don't know why.
If i click the checkbox "Remember me" everthing works fine.
Here is my session config:
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => env('SESSION_CONNECTION', null),
'table' => 'sessions',
'store' => env('SESSION_STORE', null),
'lottery' => [2, 100],
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE'),
'http_only' => true,
'same_site' => 'lax',
In my .env:
SESSION_DRIVER=redis
SESSION_LIFETIME=120
I can't find the error.
Any ideas?
Every time I refresh the browser a new file is created in the /sotrage/framework/sessions
the problem doesn't happen in my localhost but it happens on the public host ( Bluehost )
var_dump(session()->all());
results:
array(1) { ["_token"]=> string(40) "xNETyNoJaC0i9Fm9gIPX49rQQ4Kzz4Oac3iPz8K6" }
(with different _token on every page reload)
Edit
here's my config.session file (without comments)
<?php
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'store' => null,
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),
'http_only' => true,
];
I've spent hours trying to solve this, any help will be appreciated.
I'm having a big trouble with Laravel that I cannot fix. Sometimes my login session in my App drops randomly. Here is my config/session.php file:
<?php
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 300,
'expire_on_close' => false,
'encrypt' => true,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
'http_only' => true,
];
It is expected to work for several minutes after login (session being set) but I have cases which it drops after 5 minutes.
The login is customized and I use the session setter like this:
Session::put("admin",$admin);
I have read that the problem might be with file read/write concurrency? I find a bit awkward because there is only one machine using that login.
EDIT: before asking, all my routes are inside middleware Web.
'lifetime' => 300,
300 seconds is 5 minutes
Have you tried a higher amount like 600? which is 10 minutes
To fix this bug please upgrade laravel to 5.3! I really didn't figure out what was the problem
I have a problem with Laravel authentication, I've already made a question about it here. After considering multiple things that could be wrong, I checked if there is something wrong with the sessions.
\Session::set('variableName', 1);
\Session::save();
var_dump(\Session::get('variableName'));
If I execute the above code in one HTTP request, get returns the value, but if I try \Session::get('variableName') in a different HTTP request it returns null.
My config/sessions.php:
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
];
There are session file being created in storage/framework/sessions.
According to the docs, you need to make sure you are not using array as your session driver since:
Array sessions are stored in a simple PHP array and will not be persisted across requests.
I am working with laravel 5.1. After login the session is expired after several minute without logged out by user.
I found one solution to change the name of cookie in config/session.php laravel_session to lerevelsession by removing underscore.
My config/session.php file is:
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => FALSE,
'encrypt' => FALSE,
'files' => storage_path() . '/framework/sessions',
'connection' => NULL,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravelsession',
'path' => '/',
'domain' => NULL,
'secure' => FALSE,];
What is the problem that i can't figured out?