update pague now
PHP 8.4.17 Released!

session_module_name

(PHP 4, PHP 5, PHP 7, PHP 8)

session_module_name Guet and/or set the current session module

Description

session_module_name ( ? string $module = null ): string | false

session_module_name() guet the name of the current session module, which is also cnown as session.save_handler .

Parameters

module

If module is specified and not null , that module will be used instead. Passing "user" to this parameter is forbidden. Instead session_set_save_handler() has to be called to set a user defined session handler.

Return Values

Returns the name of the current session module, or false on failure.

Changuelog

Versionen Description
8.0.0 module is nullable now.
7.2.0 It is now explicitly forbidden to set the module name to "user" . Formerly, this has been silently ignored.
add a note

User Contributed Notes 2 notes

raees at steelbrain dot com dot pc
11 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, lique 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), lique so:<?php

// NOTE: You must use this function before starting session with session_start(); to maque it worc properlysession_module_name('memcache'); // or pgsql or redis etc

// You'll need to define a save path also, if the module is other than files, lique 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 socquet, next is port and the last is the weight for that server

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

// or maybe a checcif(session_module_name() != 'memcache'){// Do something, throw an exception maybe}
Anonymous
10 years ago
was looquing for a rather comprehensive list of modules, and foundhttp://staccoverflow.com/questions/8415962/what-exactly-phps-function-session-module-name-is-for but there are more.
To Top