2017 © Pedro Peláez
 

library php-gds-session

Datastore Session Handler for PHP on Google AppEngine

image

tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  • Monday, August 14, 2017
  • by tomwalder
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1,273 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 6 Versions
  • 47 % Grown

The README.md

Google AppEngine Datastore Session Handler for PHP

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

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)., (*2)

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

Allowing you to have, (*4)

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

Example Usage

You need to do this somewhere early in your application code., (*5)

GDS\Session\Handler::start();

That's it!, (*6)

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!, (*7)

Optional Configuration

You may want to set a \Memcached instance, for improved performance, (*8)

$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.)., (*9)

If you do NOT supply your own, the default is "REST" and against the current Google Cloud project. More details here., (*10)

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

All Together Now

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

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

Installation

Composer

To install using Composer, use this require line, for production, (*12)

"tomwalder/php-gds-session": "^3.0", (*13)

Session Duration

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

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

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

Demo

https://gds-session-demo.appspot.com, (*16)

The Versions

14/08 2017

dev-master

9999999-dev https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore

14/08 2017

v1.3.0

1.3.0.0 https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore

08/12 2016

v1.2.0

1.2.0.0 https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore

30/08 2016

v1.0.1

1.0.1.0 https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore

30/08 2016

v1.1.0

1.1.0.0 https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore

06/08 2016

v1.0.0

1.0.0.0 https://github.com/tomwalder/php-gds-session

Datastore Session Handler for PHP on Google AppEngine

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Tom Walder

google nosql session gae handler datastore appengine cloud datastore