Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

As PHP version 5.5 is no longer supported by the community, we strongly recommend new apps use the PHP 7+ runtime.

\google\appengine\ext\session\MemcacheSessionHandler

Stay organized with collections Save and categorize content based on your preferences.

FINAL

A session handler interface using the GAE Memcache API.

Implements

]

Constants

SESSION_PREFIX

Methods

__construct

__construct(\google\appengine\ext\session\MemcacheContainer $memcacheContainer = null)

Constructs the session handler instance.

Parameters

Name Description

$memcacheContainer

\google\appengine\ext\session\MemcacheContainer

Optional, for mocking in tests

open

open(string $savePath, string $sessionName) : boolean

Opens the session handler.

Parameters

Name Description

$savePath

string

Not used

$sessionName

string

Not ued

Returns

boolean

true if successful, false otherwise

close

close() : boolean

Closes the session handler.

Returns

boolean

true if successful, false otherwise

read

read(string $id) : string

Read an element from Memcache with the given ID.

Parameters

Name Description

$id

string

Session ID associated with the data to be retrieved

Returns

string

data associated with that ID or bool false on failure

write

write(string $id, string $data) : boolean

Write an element to Memcache with the given ID and data.

Parameters

Name Description

$id

string

Session ID associated with the data to be stored

$data

string

Data to be stored

Returns

boolean

true if successful, false otherwise

destroy

destroy(string $id) : boolean

Destroy the data associated with a particular session ID.

Parameters

Name Description

$id

string

Session ID associated with the data to be destroyed

Returns

boolean

true if successful, false otherwise

gc

gc(integer $maxlifetime) : boolean

Garbage collection method - always returns true as this is handled by the Memcache expire function.

Parameters

Name Description

$maxlifetime

integer

Not used

Returns

boolean

true if successful, false otherwise

configure

STATIC   

configure(\google\appengine\ext\session\MemcacheContainer $memcacheContainer = null)

Configure the session handler to use the Memcache API.

Parameters

Name Description

$memcacheContainer

\google\appengine\ext\session\MemcacheContainer

Optional, for mocking in tests