PHP 7.2.0 Beta 1 Released


(PHP 4, PHP 5)

session_module_nameAssume o imposta il corrente modulo di sessione


string session_module_name ([ string $module ] )

session_module_name() restituisce il nome del corrente modulo di sessione. Se module è specificato, sarà invece usato quel modulo.

add a note add a note

User Contributed Notes 3 notes

raees at steelbrain dot com dot pk
2 years ago
This function is used to set the Session Module at site or script level.

The global configuration can be done in php.ini under the [Session] section and with the name of "session.save_handler". The sessions are saved in files by default, like so:
session.save_handler = files

But with this configuration you set one of your websites to use some other session module (if you have them installed and extension loaded with PHP), like so:

// NOTE: You must use this function before starting session with session_start(); to make it work properly
session_module_name('memcache'); // or pgsql or redis etc

// You'll need to define a save path also, if the module is other than files, like so:
session_save_path('localhost:11211'); // memcache uses port 11211

// or you can use multiple for load balancing:
session_save_path('localhost:11211:41,otherhost:11211:60') // First part is hostname or path to socket, next is port and the last is the weight for that server

//The function also returns the value of the current session module.
echo session_module_name(); // will print memcache in our case

// or maybe a check
if(session_module_name() != 'memcache'){
// Do something, throw an exception maybe
2 years ago
was looking for a rather comprehensive list of modules, and found but there are more.
ts9904247885 at gmail dot com
3 years ago


//echo session_encode()."<br/>";//Prints all Session Data
//echo session_is_registered($n);
echo session_module_name();//it prints "files"


To Top