session - PHP cookie variable getting deleted between programs -
i tried searching issue on forum not it. making new post. request redirect me right solution if available.
problem: trying use facebook login in program using javascript sdk. once user's acceptance validated, passing user php program validates whether email id registered, connects accounts , redirects user homepage.
i trying register userid of user in cookie in validation program. problem when var_dump on $_cookie on last line of validation program, able see variable called userid when same on first line of homepage, not see variable. cookie variable getting lost somewhere between pages.
both pages have session_start() first line of code.
thanks in anticipation.
regards, himanshu
code added
setcookie("user", $user, time()-86400); setcookie("user", $user, time()+86400,"/"); setcookie("userid", $id, time()-86400); setcookie("userid", $id, time()+86400,"/"); setcookie("name", $fname, time()-86400); setcookie("name", $fname, time()+86400,"/"); setcookie("fb", '1', time()-86400); setcookie("fb", '1', time()+86400,"/"); if((!$_session['where'])||($_session['where'] == '')) { header("location: http://www.xyz.com/mypage.php"); } else { header("location: $url"); }
in mypage.php, first 2 lines under:
<?php session_start(); print_r($_cookie);
hope clearer now
are using setcookie
in addition setting $_cookie variable? setcookie
writes cookie file while $_cookie state of user has cookies on page load.
simpler version : write setcookie
, read $_cookie. if need $_cookie accessible right now, set $_cookie along setcookie call.
example :
<?php //write setcookie('name', $value, $expirationinseconds); $_cookie['name'] = $value; //read $id = $_cookie['name'];
Comments
Post a Comment