PHPackages                             bvisonl/inactivity-bundle - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bvisonl/inactivity-bundle

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bvisonl/inactivity-bundle
=========================

Symfony2 Bundle to handle user Inactivity and Session idle time outs

v1.0.0(8y ago)032MITPHPPHP &gt;=5.6.0

Since Aug 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/bvisonl/inactivity-bundle)[ Packagist](https://packagist.org/packages/bvisonl/inactivity-bundle)[ RSS](/packages/bvisonl-inactivity-bundle/feed)WikiDiscussions master Synced 2w ago

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

BvisonlInactivityBundle
=======================

[](#bvisonlinactivitybundle)

Introduction
------------

[](#introduction)

The purpose of this bundle is to provide a "better" way of handling the log in session of an User in Symfony2. While handling multiple tabs opened and client idletime.

I have to thank () for giving me the ideas of how to implement this. Sadly, that bundle was not working properly for me and also it just covered the client part of the issue that I was having so I decided to just make something that merged both client and server.

Pre-requisites
--------------

[](#pre-requisites)

This bundle depends on store.js ==&gt;

Installation
------------

[](#installation)

1. Install via composer

```
composer require bvisonl/inactivitybundle 1.x

```

2. Add to the AppKernel

```
 public function registerBundles()
    {
        $bundles = array(
        ...
        new Bvisonl\InactivityBundle\BvisonlInactivityBundle(),
        ...
        );
    }

```

3. Define the *bvisonl\_session\_timeout* parameter in your parameters.yml

```
parameters:
    bvisonl_session_lifetime: 300 # 5 minutes

```

If you are using the *cookie\_lifetime*, set it up to a very high value in your config.yml:

```
session:
    ...
    cookie_lifetime: 300000000000 # Set this value high enough and let the bundle handle the session inactivity

```

Also, if you intend to use this parameter in your HTML (as shown below). You must define it in your twig globals in your config.yml:

```
# Twig Configuration
twig:
    ...
    globals:
        bvisonl_session_lifetime: "%bvisonl_session_lifetime%"

```

4. Add the javascript somewhere in your HTML (i.e. in the base.html.twig)

```
{% javascripts '@BvisonlInactivityBundle/Resources/public/js/inactivity.handler.js' %}

{% endjavascripts %}

```

5. Configure the JS plugin to check for user activity

```

    $(document).ready(function() {
        $.fn.bvisonlInactivityHandler({
            // This is the default configuration, in reality no parameter is required but check that the defaults are ok for you
            sessionTimeout: {{ bvisonl_session_lifetime }}, // Default is 300 (5 minutes)
            logoutUrl: "{{ path('fos_user_security_logout') }}", // Default is "/"
            pingServer: true, // Default is false
            pingUrl: '/bvisonl/inactivity/ping', // Url to ping to keep session alive in the server, MUST RETURN A 204 response
            pingInterval: {{ bvisonl_session_lifetime/2 }}, // Default is 150
            events: 'click keypress scroll wheel mousewheel mousemove keyup', // Default events to check on the browser
        });
    })

```

6. Add the routes of the bundle in the routing.yml if using default ping function:

```
# BvisonlInactivityBundle Routes
bvisonl_inactivity:
    resource: "@BvisonlInactivityBundle/Resources/config/routing.yml"

```

7. Remember to clear your cache, install assets, and if using assetic to install them as well

```
php app/console assets:install --env=dev
php app/console assetic:dump --env=dev
php app/console cache:clear --env=dev

```

How it works
------------

[](#how-it-works)

Basically, if configured as shown above, the process divides itself in 2:

#### ~ Server

[](#-server)

On the server, there is a listener that keeps...well...listening the last time a session was used, and compares it to the session\_lifetime parameter. If the session should be destroyed, then it will be destroyed. Simple enough for the server.

#### ~ Client

[](#-client)

In Symfony2, if you do not affect the session for a configurable amount of time, the session will be destroyed and you won't be able to perform any requests to any secured route. However, let's say that an user is analyzing a very complex report on screen scrolling around and you have the lifetime of your session to 5 minutes, when the user finishes working on the report and attempts to move around the app. On the next request, Symfony2 will re-route the user to the login screen.

To solve this, the plugin takes care of tracking the configured events and maintaining timers (using the store.js). Also, in conjunction with the pingServer functionality, the client will keep pinging the server (which should return a 204, 200 is no good since Symfony2 may return code 200 when redirecting the request to the login screen, if you use the default settings you shouldn't worry about this) everytime the client pings the server, it tells Symfony2's session that the user is still active therefore it won't log them off.

Todo
----

[](#todo)

- Maybe: Add dialog window before logging out

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3242d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4421747?v=4)[Benjamín Visón](/maintainers/bvisonl)[@bvisonl](https://github.com/bvisonl)

---

Top Contributors

[![bvisonl](https://avatars.githubusercontent.com/u/4421747?v=4)](https://github.com/bvisonl "bvisonl (11 commits)")

### Embed Badge

![Health badge](/badges/bvisonl-inactivity-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bvisonl-inactivity-bundle/health.svg)](https://phpackages.com/packages/bvisonl-inactivity-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51390.8k3](/packages/web-auth-webauthn-framework)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

65474.5k9](/packages/web-auth-webauthn-symfony-bundle)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128790.7k](/packages/auth0-symfony)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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