php - How to get cookie value -


creating cookie

session_start(); $params = session_get_cookie_params();     setcookie(session_name('username'),'hamza',1,       isset($params['path']),       isset($params['domain']),       isset($params['secure']),       isset($params['httponly']));  session_regenerate_id(true); echo "cookie created !"; 

now fetching cookie value

session_start(); $name=$_cookie['username']; echo $_cookie["username"];  if(isset($name)) {       if($name=='username')       {           echo "success";       }       else      {           echo "error";             }      } 

please me !

result

why create auto random value like: u8omuum6c9pkngrg4843b3q9m3). want original cookie value "hamza" ?????

this the format of cookie creation

syntax

setcookie(name, value, expire, path, domain, secure, httponly); 

so first variable cookie name

you can read using

$_cookie['your cookie name']; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -