@shyann
To prevent session or cookie refresh in Laravel, you can follow these steps:
- Update the config/session.php file in your Laravel project.
- Set the value of the lifetime option to a higher value, such as 120 minutes, to extend the session timeout.
- Set the value of the expire_on_close option to false to prevent the session from expiring when the browser is closed.
- Set the value of the same_site option to 'none' to allow cross-site cookies for session persistence.
Here is an example of how the updated session configuration might look like:
1
2
3
4
5
6
|
return [
// ...
'lifetime' => 120,
'expire_on_close' => false,
'same_site' => 'none',
];
|
- Additionally, you can also set the HttpOnly flag to false in the config/session.php file to allow JavaScript access to the session cookie. However, this is not recommended for security reasons.
1
2
3
4
|
return [
// ...
'http_only' => false,
];
|
By adjusting these session configuration options, you can prevent the session or cookie from refreshing and maintain persistent sessions in Laravel.