PHP - session_save_path() 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_save_path() is used to set or retrieve the path where the current session data is saved.

Syntax

session_save_path([$path ] );

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 path of the directory in which the current session data is stored.

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_save_path() function.

   
   
      Setting up a PHP session
      
   
      
      
 

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

path: /data

Example 2

You can also set the session save path using this function as shown below −

   
   
      Setting up a PHP session
      
   
      
      
 

This will produce the following output −

path: /data
php_function_reference.htm
Advertisements