Download the PHP package ycs77/laravel-recover-session without Composer
On this page you can find all versions of the php package ycs77/laravel-recover-session. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ycs77/laravel-recover-session
More information about ycs77/laravel-recover-session
Files in ycs77/laravel-recover-session
Package laravel-recover-session
Short Description Recover Laravel session when form post back from third-party API.
License MIT
Homepage https://github.com/ycs77/laravel-recover-session
Informations about the package laravel-recover-session
Laravel Recover Session
Recover Laravel session when sending a form post request back from a third-party API like NewebPay.
Currently, Laravel's default Cookie SameSite value is set to Lax
. This setting prevents cookies from being sent when using form post requests to transmit data to websites on other domains. Consequently, after completing a payment and being redirected back to the original website, users may appear to be automatically logged out due to the inability to retrieve the original login cookie. This package addresses and resolves this issue.
Installation
Via Composer:
Publish config:
Usage
Now you need to call RecoverSession::preserve()
to save the current session ID into the cache and include the key in your callback URL. This allows the current session to be resumed after the API returns with the key:
This package will automatically retrieve the encrypted session ID from the callback URL and restore the original session state upon returning to the site.
Reference details for the SameSite: https://developers.google.com/search/blog/2020/01/get-ready-for-new-samesitenone-secure
Manually Register Middleware
If you are not using the global recover session, you can set the config recover-session.global
to false
, and adjust the order of the middleware so that RecoverSession
is placed below StartSession
. by default, Laravel's Kernel
does not include the $middlewarePriority
property, so you need to add it manually.
If you are using Laravel 9 or 10, you should add the $middlewarePriority
property in your application's app/Http/Kernel.php
file:
If you are using Laravel 11+, you can add the RecoverSession
middleware to the $middlewarePriority
property in the app/Http/Kernel.php
file:
If you are using Laravel 11.31+, it provides a concise method to append middleware to the priority list:
Final, you can add the RecoverSession
middleware to the callback route for the API:
Sponsor
If you think this package has helped you, please consider Becoming a sponsor to support my work~ and your avatar will be visible on my major projects.
Credits
License
MIT LICENSE
All versions of laravel-recover-session with dependencies
illuminate/cache Version >=9.0
illuminate/config Version >=9.0
illuminate/contracts Version >=9.0
illuminate/encryption Version >=9.0
illuminate/http Version >=9.0
illuminate/session Version >=9.0
illuminate/support Version >=9.0
symfony/http-foundation Version >=6.0