• PHP Video Tutorials

PHP - session_module_name() Function



Definition and Usage

Sessions or session handling is a way to make the data available across various pages of a web application. The session_module_name() is used to set or retrieve the save handler/module of the current session.

Syntax

session_module_name([$module] );

Parameters

Sr.No Parameter & Description
1

path(Optional)

This is a string value representing the path where the session data is to be stored.

Return Values

This function returns a string value representing the name of the current session module.

PHP Version

This function was first introduced in PHP Version 4 and works in all the later versions.

Example 1

Following example demonstrates the usage of the session_module_name() function.

<html>   
   <head>
      <title>Setting up a PHP session</title>
   </head>   
   <body>
      <?php  	
         //Retrieving the module name
         $res = session_module_name();			 
         //Starting the session
         session_start();		
         print("Module Name: ".$res);	 		 
      ?>
   </body>   
</html> 

One executing the above html file it will display the following message −

Module Name: files

Example 2

You can set the module name of the current session using this function as shown below −

<html>   
   <head>
      <title>Setting up a PHP session</title>
   </head>   
   <body>
      <?php  	
         //Setting the module name
         session_module_name("files");	
         $res = session_module_name();			 
		 
         //Starting the session
         session_start();		
         print("Module Name: ".$res);	 		 
      ?>
   </body>   
</html> 

This will produce the following output −

Module Name: files
php_function_reference.htm
Advertisements