PHP 5 has reached end of support and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of PHP.
\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
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
STATIC
configure(\google\appengine\ext\session\MemcacheContainer $memcacheContainer = null)
Configure the session handler to use the Memcache API.
Parameters
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThis is a session handler interface designed for use with the Google App Engine (GAE) Memcache API.\u003c/p\u003e\n"],["\u003cp\u003eThe handler includes methods for constructing, opening, closing, reading, writing, and destroying session data within Memcache.\u003c/p\u003e\n"],["\u003cp\u003eIt also features a garbage collection method (\u003ccode\u003egc\u003c/code\u003e) that always returns true, as Memcache handles expiration.\u003c/p\u003e\n"],["\u003cp\u003eThe handler is configurable using a \u003ccode\u003eMemcacheContainer\u003c/code\u003e, which is optional and can be used for mocking during tests.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eopen\u003c/code\u003e and \u003ccode\u003egc\u003c/code\u003e methods do not utilize the parameters passed to them.\u003c/p\u003e\n"]]],[],null,["# \\google\\appengine\\ext\\session\\MemcacheSessionHandler\n\nFINAL\n\nA session handler interface using the GAE Memcache API.\n\nImplements\n----------\n\n[\\]]()\n\nConstants\n---------\n\n### SESSION_PREFIX\n\nMethods\n-------\n\n### __construct\n\n`__construct(\\google\\appengine\\ext\\session\\MemcacheContainer `$memcacheContainer = null`) `\n\nConstructs the session handler instance.\n\n#### Parameters\n\n### open\n\n`open(string `$savePath`, string `$sessionName`) : boolean`\n\nOpens the session handler.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\ntrue if successful, false otherwise\n\n### close\n\n`close() : boolean`\n\nCloses the session handler.\n\n#### Returns\n\n`boolean`\n\ntrue if successful, false otherwise\n\n### read\n\n`read(string `$id`) : string`\n\nRead an element from Memcache with the given ID.\n\n#### Parameters\n\n#### Returns\n\n`string`\n\ndata associated with that ID or bool false on failure\n\n### write\n\n`write(string `$id`, string `$data`) : boolean`\n\nWrite an element to Memcache with the given ID and data.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\ntrue if successful, false otherwise\n\n### destroy\n\n`destroy(string `$id`) : boolean`\n\nDestroy the data associated with a particular session ID.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\ntrue if successful, false otherwise\n\n### gc\n\n`gc(integer `$maxlifetime`) : boolean`\n\nGarbage collection method - always returns true as this is handled by the\nMemcache expire function.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\ntrue if successful, false otherwise\n\n### configure\n\n\nSTATIC\n\n`configure(\\google\\appengine\\ext\\session\\MemcacheContainer `$memcacheContainer = null`) `\n\nConfigure the session handler to use the Memcache API.\n\n#### Parameters"]]