unset session php -


according manual "do not unset whole $_session unset($_session) disable registering of session variables through $_session superglobal."

<?php session_start();  $_session['name'] = 'my_name';  unset($_session);  echo $_session['test'] = 'ok'; 

so according manual, above code should not register last statement. code outputs string 'ok'. going on here?

it doesn't disable sessions. disables use of session_register. not big deal, session_register has been deprecated long time:

e.g. code:

<?php  $foo = 'bar'; session_register('foo'); print_r($_session); unset($_session); session_register('foo', 'bar2'); print_r($_session);               // line 8 $_session['foo'] = 'bar3'; print_r($_session); 

you get

array (     [foo] => ) php notice:  undefined variable: _session in /home/marc/z.php on line 8 array (     [foo] => bar3 ) 

note warning. you've unset $_session, try session_register... doesn't create new $_session, fails.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -