Home > Backend Development > PHP Tutorial > Detailed explanation based on the difference between session_unset and session_destroy_PHP tutorial

Detailed explanation based on the difference between session_unset and session_destroy_PHP tutorial

WBOY
Release: 2016-07-21 15:09:58
Original
906 people have browsed it

session_unset()
Release all $_SESSION variables currently created in the memory, but do not delete the session file and do not release the corresponding sessionid
session_destroy()
Delete the current user's corresponding session file and release the sessionid, the contents of the $_SESSION variable in the memory are still retained
Therefore, to release all the resources of the user's session, the following code needs to be executed sequentially:
Program code

Copy code The code is as follows:

$_SESSION['user'] = 'wangh';
session_unset( );
session_destroy();
?>

If you just call session_destroy();
then echo $_SESSION['user'] is still valuable
That is, the content of the $_SESSION variable in the memory is still retained
[ Session]
session.save_handler = files ; Control method for saving/retrieving data
session.save_path = C:wintemp ; Parameters passed to the controller when save_handler is set to a file,
; this is the path where the data file will be saved. The folder must be created in advance
session.use_cookies = 1 ; Whether to use cookies 1 yes, 0 no
session.name = PHPSESSID
; The name of the session used in the cookie
session.auto_start = 0                                                                                                  _path = / ; Valid path of cookie
session.cookie_domain = ; Valid domain of cookie
session.serialize_handler = php ; Controller used to connect data
; php is the standard controller of PHP.
session.gc_probability = 1 ; Probability as a percentage of the 'garbage collection' process to start at each session initialization.
session.gc_maxlifetime = 1440 ; After the number of seconds indicated by the number here, the saved data will be considered
                                                 ;
Session.refer_check =; Check the http reference to make the additional include an additional IDS in the URLS. ION id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache; set to {nocache,private,public} to determine the HTTP
; cache Problem
session.cache_expire = 180 ; Document expires after n minutes
session.use_trans_sid = 1 ; Use transitional sid support if enabled at compile time ; ; --enable-trans-sid
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327178.htmlTechArticlesession_unset() releases all $_SESSION variables currently created in memory, but does not delete the session file and does not release The corresponding sessionid session_destroy() deletes the corresponding sessionid of the current user...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template