I am creating cookies in a loginform.php file like this :
$time = time();
setcookie('myusername', $myusername, $time +60*60*24*200); // Sets the cookie username
setcookie('myuserid', $rows['userid'], $time +60*60*24*200); // Sets the cookie password
setcookie('myname', $rows['name'], $time +60*60*24*200);
this file is located in a folder named login which is located in the root directory of my website.
I am able to retrieve the cookies in loginform.php but not at anyother file in the root directory ..
What may be the problem ?
From manual,
You need to set the cookie path to
/to access it from anywhere. So it’ll be like,Its not a good idea to set sensitive information like username or user id in cookie. Any one can change the value and become someone else.
Its better to use Session. Even the session id will be saved in cookie but its hard to guess another session id.