PHPackages                             substacks/mongosession - 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. substacks/mongosession

ActiveLibrary

substacks/mongosession
======================

A PHP session handler wrapped around MongoDB. https://www.coreyballou.com

v1.0.0(9y ago)012MITPHP

Since Apr 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/SubStacks/MongoSession)[ Packagist](https://packagist.org/packages/substacks/mongosession)[ RSS](/packages/substacks-mongosession/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Overview
--------

[](#overview)

The MongoSession PHP session handler class was built as a drop-in for easily switching to handling sessions using Mongo. It's a great replacement to memcache(d) for VPS servers where you risk memory being reshuffled in the pool and taking performance hits. There are currently inherent risks in using MongoDB as your session handler that you can read about on the documentation page:

The session handler has recently been updated to perform atomic updates as a quick (although not 100% effective) patch regarding the issue of race conditions caused by issuing AJAX commands. This generally shouldn't be a problem for most sites unless you are performing a series of AJAX requests which modify the same session data fields asynchronously.

Default Usage
-------------

[](#default-usage)

If you only have a single server running Mongo on localhost, you can simply load the class and it'll use default config values. There's no need to create the database or collection in advance, as such functionality does not exist in Mongo. If neither the database nor collection exist, they will be created upon the first session insert. Please bare in mind this code should be placed at the top of your files before you make any calls to header():

```
