PHPackages                             tomwalder/php-gds-session - 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. tomwalder/php-gds-session

ActiveLibrary

tomwalder/php-gds-session
=========================

Datastore Session Handler for PHP on Google AppEngine

v4.1.0(3y ago)713.3k↓50%3[4 issues](https://github.com/tomwalder/php-gds-session/issues)Apache-2.0PHPPHP &gt;=7.0

Since Aug 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/tomwalder/php-gds-session)[ Packagist](https://packagist.org/packages/tomwalder/php-gds-session)[ Docs](https://github.com/tomwalder/php-gds-session)[ RSS](/packages/tomwalder-php-gds-session/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (11)Used By (0)

Google AppEngine Datastore Session Handler for PHP
==================================================

[](#google-appengine-datastore-session-handler-for-php)

Google App Engine uses Memcache to store session data by default (specifically the Standard PHP Runtime).

This is bad. It means that session data disappears from time to time, as the shared Memcache is rotated. This will log out any signed in users (as well as lose any session data).

This library provides a Datastore + Memcache alternative session handler. It means that your session data is persisted, not just kept in memory.

Allowing you to have

- More reliable user sign in (less random-log-outs)
- Much longer sessions

Example Usage
-------------

[](#example-usage)

You need to do this somewhere early in your application code.

```
GDS\Session\Handler::start();
```

That's it!

This will replace the default Memcache session handler with a shiny new one. This method does call `session_start()` so make sure you're not doing that too!

### Optional Configuration

[](#optional-configuration)

You may want to set a `\Memcached` instance, for improved performance

```
$mc = new Memcached('mc');
$mc->addServer('127.0.0.1', 11211);
GDS\Session\Handler::setMemcached($mc);
```

You may want to supply your own GDS Gateway instance, configured to point at the correct project with the right protocol (gRPC / REST etc.).

If you do NOT supply your own, the default is "REST" and against the current Google Cloud project. [More details here](https://github.com/tomwalder/php-gds/blob/master/src/GDS/Store.php#L82).

```
$gw = new \GDS\Gateway\GRPCv1('my-project-id');
GDS\Session\Handler::setGateway($gw);
```

### All Together Now

[](#all-together-now)

Your setup might look like this with Memcached as custom Gateway. It's recommended to call `::start()` last.

```
// ... configure Memcached & Gateway
GDS\Session\Handler::setMemcached($mc);
GDS\Session\Handler::setGateway($gw);
GDS\Session\Handler::start();
```

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

[](#installation)

### Composer

[](#composer)

To install using Composer, use this require line, for production

`"tomwalder/php-gds-session": "^3.0"`

Session Duration
----------------

[](#session-duration)

By default, the handler uses 1 day (86,400 seconds) for session duration.

You can set your own custom duration by passing it in to the `start()` method, like this:

```
GDS\Session\Handler::start(3600);
```

Demo
----

[](#demo)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance9

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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

Every ~309 days

Recently: every ~525 days

Total

9

Last Release

1098d ago

Major Versions

v1.3.0 → v2.0.02018-10-30

v2.0.0 → v3.0.02022-03-15

v3.0.0 → v4.0.02022-05-09

PHP version history (3 changes)v1.0.0PHP &gt;=5.5.4

v3.0.0PHP &gt;=7.0

v4.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4e0f7bb9ed3cd1e6c7d0068cf6d446cab11ec0908a0328e807a3db9a14f7e63?d=identicon)[tomwalder](/maintainers/tomwalder)

---

Top Contributors

[![tomwalder](https://avatars.githubusercontent.com/u/1258131?v=4)](https://github.com/tomwalder "tomwalder (6 commits)")[![wojciechg4m](https://avatars.githubusercontent.com/u/97453406?v=4)](https://github.com/wojciechg4m "wojciechg4m (3 commits)")[![scragar](https://avatars.githubusercontent.com/u/134325?v=4)](https://github.com/scragar "scragar (1 commits)")

---

Tags

googlehandlernosqlsessionappenginedatastoregaecloud datastore

### Embed Badge

![Health badge](/badges/tomwalder-php-gds-session/health.svg)

```
[![Health](https://phpackages.com/badges/tomwalder-php-gds-session/health.svg)](https://phpackages.com/packages/tomwalder-php-gds-session)
```

###  Alternatives

[tomwalder/php-gds

Google Cloud Datastore Library for PHP. Also Firestore in Datastore mode.

161174.0k5](/packages/tomwalder-php-gds)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[google/appengine-php-sdk

Google App Engine PHP SDK

30764.5k4](/packages/google-appengine-php-sdk)[tomwalder/php-appengine-search

Google App Engine Search Library for PHP

242.2k](/packages/tomwalder-php-appengine-search)

PHPackages © 2026

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