|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37484 Need a more clearer documenation on session's save_handler w/ shared memory.
Submitted: 2006-05-17 21:32 UTC Modified: 2007-08-17 21:46 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: scott at abcoa dot com Assigned: ramsey (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2006-05-17 21:32 UTC] scott at abcoa dot com
Documentation's URL:

Problem: Some confusion and hard to read on the use of "mm" or shared memory.  I discovered that there are 3 options which are "files", "mm" and "users" to be used with the sessions.save_handler but the documentation didn't mentioned that.  I had spend quite some time looking for more information that would shed some lights about those.

Solution:  Update the 

session.save_handler  string

    session.save_handler defines the name of the handler which is used for storing and retrieving data associated with a session. Defaults to files. See also session_set_save_handler(). 

section to include the 3 options and explain the purpose of the 3 options.  Example of it can be found at .  Good example would be 

Storage Modules
To read and save session data, PHP uses storage modules, thus abstracting the back end of the library. There are currently three storage modules available:

    * Files. By default, PHP uses the files module to save the session data to disk. It creates a text file named after the session ID in /tmp. You probably won't ever need to access this file directly. In the example of the session counter, the content of this file would look like this, which is a serialized representation of the variable: counter|i:4;
    * mm. If you need higher performance, the mm module is a viable alternative; it stores the data in shared memory and is therefore not limited by the hardware I/O system.
    * User. Used internally to realize user-level callback functions that you define with session_set_save_handler(). 

The real power lies in the capacity to specify user callbacks as storage modules. Because you can write your functions to handle sessions while still being able to rely on the standardized PHP API, you can store sessions wherever and however you want: in a database like MySQL, XML files, on a remote FTP server (an FTP server is unlikely, but you get the idea).
The function session_set_save_handler() takes six strings as arguments, which must be your callback functions.

The syntax of the function is as follows:
void session_set_save_handler(string open, string close, string read, string write, string destroy, string gc);

To leave out one argument, pass an empty string ("") to session_set_save_handler().

We would also need to explain that session_set_save_handler() that contain up to 6 arguements are not the same things as setting the session.save_handler that is either 1 of the 3 following options, "files", "mm", and "users".  Another confusion here...

Might be a good idea to mention that compiling with the shared memory module may be needed for "mm" option to work as specified in the "Installation" section of this's session documentation.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-17 21:49 UTC] scott at abcoa dot com
HOw come there are two related documentation on session.  See one at
 [2006-05-18 01:28 UTC]
See bug #35755. I'm going to take on the task of updating the session docs to describe the different storage modules and how PHP needs to be configured in order to use the "mm" module.
 [2006-05-18 13:00 UTC] scott at abcoa dot com
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 12:01:29 2024 UTC