PHPackages                             quantical-solutions/session-out-modal-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. quantical-solutions/session-out-modal-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

quantical-solutions/session-out-modal-laravel
=============================================

Notify the user via modal if session expired

1.0.0(5y ago)0133MITBladePHP &gt;=7.1.3

Since Mar 10Pushed 4y agoCompare

[ Source](https://github.com/Quantical-Solutions/package-session-out)[ Packagist](https://packagist.org/packages/quantical-solutions/session-out-modal-laravel)[ Docs](https://github.com/quantic/laravel-session-out)[ RSS](/packages/quantical-solutions-session-out-modal-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Session expired message for your Laravel application
====================================================

[](#session-expired-message-for-your-laravel-application)

[![EPSI CI](https://github.com/Quantical-Solutions/package-session-out/actions/workflows/blank.yml/badge.svg?branch=main)](https://github.com/Quantical-Solutions/package-session-out/actions/workflows/blank.yml)Upgraded version from [devsrv / laravel-session-out](https://github.com/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 &amp; 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 &amp; 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
--------------

[](#--installation)

You can install the package via composer:

```
composer require quantical-solutions/laravel-session-out
```

> Laravel 5.5+ users: this step may be skipped, as we can auto-register the package with the framework.

```
// Add the ServiceProvider to the providers array in
// config/app.php

'providers' => [
    '...',
    'Quantic\SessionOut\SessionExpiredServiceProvider::class',
];
```

You need to publish the `blade`, `js`, `css` and `config` files included in the package using the following artisan command:

```
php artisan vendor:publish --provider="Quantic\SessionOut\SessionExpiredServiceProvider"
```

⚗️ Usage
--------

[](#️-usage)

just include the blade file to all the blade views which are only available to authenticated users.

```
@include('vendor.session-out.notify')
```

> rather copying this line over &amp; over to the views, extend your base blade view and include it there in the bottom

🛠 Configuration
---------------

[](#--configuration)

#### ✔ The Config File

[](#-the-config-file)

publishing the vendor will create `config/expired-session.php` file

```
return [

    // whether using broadcasting feature to make the modal disappear faster
    'avail_broadcasting' => false,
];
```

#### ✔ If you want to take advantage of broadcasting

[](#-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

1. setup [broadcasting](https://laravel.com/docs/master/broadcasting) for your app and start `usersession` queue worker

```
php artisan queue:work --queue=default,usersession
```

2. make sure to put the broadcasting client config `js` file after the `@include` line not below it, in your blade view.

```
@include('vendor.session-out.notify')
```

> Don't forget to include the require("./session" in resources/js/app.js) just after the last require.

```
require("./bootstrap");
require("alpinejs");
require("./session");

// Your JavaScript code...
```

3. in `App\Providers\BroadcastServiceProvider` file in the `boot` method require the package's channel file, it contains private channel authentication

```
require base_path('vendor/quantical-solutions/session-out-modal-laravel/src/routes/channels.php');
```

4. 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 :-

```
// App\Providers\EventServiceProvider

protected $listen = [
        'Illuminate\Auth\Events\Login' => [
            'App\Listeners\SuccessfulLogin',
        ],
    ];
```

```
// App\Listeners\SuccessfulLogin

use Quantic\SessionOut\Classes\AuthState;

/**
* Handle the event.
*
* @param  Login  $event
* @return void
*/
public function handle(Login $user)
{
	AuthState::sessionAvailable();
}
```

5. Got to the VerifyCsrfToken Middleware file and add '/check-auth' in the excluded URIs array

```
namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/check-auth',
        '/session',
        '/rebirth-session'
    ];
}
```

6. Finally uncomment et use your presets from .env file to fill the Echo params in resources/js/bootstrap.js

```
window._ = require('lodash');

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({
     broadcaster: 'pusher',
     key: process.env.MIX_PUSHER_APP_KEY,
     cluster: process.env.MIX_PUSHER_APP_CLUSTER,
     forceTLS: true
});
```

> Don't forget to install Echo &amp; Pusher

```
npm install --save-dev laravel-echo pusher-js
npm run dev
```

#### ✔ Update the modal design &amp; contents

[](#-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` &amp; the design by editing `public/vendor/session-out/css/session-modal.css`

#### ✔ Advanced

[](#-advanced)

- 🔘 if you want to customize the `js` file which is responsible for checking auth session &amp; modal display then modify the `resources/js/session.js`

> after ajax success close the modal by calling the `closeSessionOutModal()` function

🧐📑 Note
-------

[](#-note)

#### ♻ When updating the package

[](#-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

```
php artisan vendor:publish --provider="Quantic\SessionOut\SessionExpiredServiceProvider" --force

php artisan vendor:publish --provider="Quantic\SessionOut\SessionExpiredServiceProvider" --tag=public --force
```

> when updating the package take backup of the `config/expired-session.php` file &amp; `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 the `assets`, `views` and `config` you may again modify the files

#### 🔧 After you tweak things

[](#-after-you-tweak-things)

Run this artisan command after changing the config file.

```
php artisan config:clear
php artisan queue:restart // only when using broadcasting
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1889d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/519b0291577d18d3873185a4fdcfd008218607fb6ee2c3995f1fffb1eee4acb1?d=identicon)[Quantical Solutions](/maintainers/Quantical%20Solutions)

---

Top Contributors

[![My-Hero-Macadamia](https://avatars.githubusercontent.com/u/66546741?v=4)](https://github.com/My-Hero-Macadamia "My-Hero-Macadamia (41 commits)")

---

Tags

laravel suggest login againlaravel expired session message

### Embed Badge

![Health badge](/badges/quantical-solutions-session-out-modal-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/quantical-solutions-session-out-modal-laravel/health.svg)](https://phpackages.com/packages/quantical-solutions-session-out-modal-laravel)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
