PHP session_set_save_handler Function

What is session_set_save_handler Function?

Explanation

The "session_set_save_handler()" function is used to set user-level session storage functions.

Syntax:


session_set_save_handler(open,close,read,write,destroy,gc)

In the above syntax the user-level session storage function, "open" is executed when the session is being opened, it has two parameters "save path" and "session name" "close" is executed when the session operation is done, "read" must return string value, "write" updates the session data, "destroy" this is executed when a session is destroyed using session_destroy, "gc" this is executed when the session garbage collector is executed.

Example :


<?php
session_set_save_handler("user_open","user_close",
"user_write","user_gc")
?>

In the above example, we have just given a sample code for session_set_save_handler() function.

PHP Topics


Ask Questions

Ask Question