This function can place all of the session variables that are of course registered as NULL. Note that it is not unregister, but also different from destroy.
The following example shows a good description of this function.
<?php
Session_register (' A ', ' ' B ', ' ' C '); Auto-session-start
$a = 1;
$b = 2;
$c = 3;
Session_unregister (' a '); Unregistrered $a
echo "A: $a-reg:". session_is_registered (' a '). "
"; But the global $a remains
Session_unset (); Unsets $b und $c
echo "B: $b-reg:". session_is_registered (' B '). "
"; The registration remains!
echo "C: $c-reg:". session_is_registered (' C '). "
";
Echo Session_encode ();
?>
Set some parameter parameters for the session cookie, similar to the setting in PHP.ini, but the settings made by this function are valid only for the current script file.
//*******************************
The following function should be useful for everyone, are you interested in customizing a session that is not saved with cookies? This function will achieve your vision.
Let me think, what's the advantage of not using cookies? At least one point, you don't have to worry about whether the client's cookie function is turned on, right.
This function can define the Save function (open, close, write, and so on) of the user-level session.
This function is useful, for example, when we want to save a session in a local database.
!!! Note: Before using this function, you must first configure the php.ini file, Session.save_hadler=user, otherwise, Session_set_save_handler () will not take effect.
Also, according to my tests, if you want this session to be used across pages, add your own functions and Session_set_save_handler to every script file that you use in the session, so the best way is to make a separate file, Include in every script that will use session.
The following example provides a basic session save method, similar to the default files method.
If you want to use the database to achieve, this is also very easy to do.
Example 1. Session_set_save_handler () example
<?php
function open ($save _path, $session _name) {
Global $sess _save_path, $sess _session_name;
/*********************************************
* Warning-you'll need to implement some *
* Sort of garbage collection routine here. *
*********************************************/
Function GC ($maxlifetime) {
return true;
}
This function can set or get the value of Session.cache_limiter.
You can also make the same settings in php.ini. Its value is nocache,public,private.
This function is sent to the client via the header of HTTP. If NoCache, the cache for any client is prohibited. Public will allow cache, but private is a little more secure than public.
The default value is the setting in php.ini, and if you want to use it, you must call this function before each call to Session_Start ().
This function can now only run in CVS mode, but PHP4.0.3 will support it.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.