Download the PHP package quantical-solutions/session-out-modal-laravel without Composer
On this page you can find all versions of the php package quantical-solutions/session-out-modal-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download quantical-solutions/session-out-modal-laravel
More information about quantical-solutions/session-out-modal-laravel
Files in quantical-solutions/session-out-modal-laravel
Package session-out-modal-laravel
Short Description Notify the user via modal if session expired
License MIT
Homepage https://github.com/quantic/laravel-session-out
Informations about the package session-out-modal-laravel
Session expired message for your Laravel application
Upgraded version from devsrv / laravel-session-out which was not maintained since Laravel v5.* so big thx to devsrv for that awesome work !
If for any reason ( user logged out intentionally / session lifetime expired / session flushed for all logged in devices of the user ) the authentication session doesn't exist & still the user is on a page or multiple pages which require the user to be logged in, then showing a message that
authentication session no longer available & to continue your current activity ( may be in the middle of posting an unsaved post etc. ), you are advised to login again
and right after user logged in then hiding the message is all about this package.
📥 Installation
You can install the package via composer:
Laravel 5.5+ users: this step may be skipped, as we can auto-register the package with the framework.
You need to publish the blade
, js
, css
and config
files included in the package using the following artisan command:
⚗️ Usage
just include the blade file to all the blade views which are only available to authenticated users.
rather copying this line over & over to the views, extend your base blade view and include it there in the bottom
🛠 Configuration
✔ The Config File
publishing the vendor will create config/expired-session.php
file
✔ If you want to take advantage of broadcasting
** if you are using
avail_broadcasting = true
i.e. want to use the Laravel Echo for faster output please follow the below steps
-
setup broadcasting for your app and start
usersession
queue worker - make sure to put the broadcasting client config
js
file after the@include
line not below it, in your blade view.
Don't forget to include the require("./session" in resources/js/app.js) just after the last require.
-
in
App\Providers\BroadcastServiceProvider
file in theboot
method require the package's channel file, it contains private channel authentication -
in all the places from where users are authenticated call
Quantic\SessionOut\Classes\AuthState::sessionAvailable()
. if you are using custom logic to login users then put the line inside your authentication method when login is successful.if you are using laravel's default authentication system then better choice will be to create a listener of the login event, Example :-
-
Got to the VerifyCsrfToken Middleware file and add '/check-auth' in the excluded URIs array
- Finally uncomment et use your presets from .env file to fill the Echo params in resources/js/bootstrap.js
Don't forget to install Echo & Pusher
✔ Update the modal design & contents
The modal is created with pure js
and css
no framework has been used, so you can easily customize the modal contents by editing the views/vendor/session-out/modal.blade.php
& the design by editing public/vendor/session-out/css/session-modal.css
✔ Advanced
- 🔘 if you want to customize the
js
file which is responsible for checking auth session & modal display then modify theresources/js/session.js
after ajax success close the modal by calling the
closeSessionOutModal()
function
🧐📑 Note
♻ When updating the package
Remember to publish the assets
, views
and config
after each update
use --force
tag after updating the package to publish the updated latest package assets
, views
and config
but remember using --force tag will replace all the publishable files
when updating the package take backup of the
config/expired-session.php
file &resources/js/session.js
,views/vendor/session-out
directories as the files inside these dirs are configurable so if you modify the files then the updated published files will not contain the changes, though after publishing theassets
,views
andconfig
you may again modify the files
🔧 After you tweak things
Run this artisan command after changing the config file.