Home >Backend Development >PHP Tutorial >Several supplementary functions about session (1)_PHP tutorial
Under PHP, there is a lot of discussion about session. In fact, there are several functions in PHP4 that we usually don't notice.
Let me introduce them to you below.
The session_set_save_handler() is really a good thing.
//**********************
session_unset (PHP4 $#@62;= 4.0b4)
void session_unset(void);
This function can set all registered session variables to empty. Note that it is not unregister, nor is it the same as destroy.
The following example provides a good explanation of this function.
$#@60;?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();
?$#@62 ;
Output:
A: 1 - reg:
B: - reg:1
C: - reg:1
!b|!c|