php - Why session doesn't recognise manual change of cookie? -
i trying understand sessions, , conducted test:
my code is:
test.php
<? @session_start(); if(isset($_session['test'])) { echo "test success"; } ?>
when enter cookie manually browser using addon as:
phpsessid test
it not recognise it.
$_session "superglobal" (available everywhere) array tied cookie using unique session id.
if you're wanting reference cookie values you've set you'll need use $_cookie superglobal array.
you can read more superglobals here: http://php.net/manual/en/language.variables.superglobals.php
and how $_session , $_cookie works here: http://php.net/manual/en/reserved.variables.cookies.php http://php.net/manual/en/reserved.variables.session.php
you cannot set values in session using browser that. php place you'll able set 'test' key value, true or false.
session_start(); // assign based on value of cookie $_session['test'] = true; if ($_session['test']) { // test session }
hope helps.
Comments
Post a Comment