Saturday, 15 September 2012

Cannot use session variable even if session has been started in php -



Cannot use session variable even if session has been started in php -

i want transfer info 1 php page other, , used session transfer it. have started session using session_start() on both pages.

page 1 : session_start(); $x=10; $_session['val']=$x; page 2 : session_start(); $value=$_session['val'];

the error pops out saying undefined index:val . please help, , explain why happening need transfer info .

try isset() !

isset() function in php determines whether variable set , not null. returns boolean value, is, if variable set homecoming true , if variable value null homecoming false.

<?php session_start(); if(isset($_session['val'])) { $value=$_session['val']; //other code } ?>

php session

No comments:

Post a Comment