PHP Simple Cookie Problem ~ ~
To do a simple website Login interface and logout interface, in the login interface of the PHP code to set a cookie, want to show in this program is not displayed, in the Logout interface code can be displayed.
The code for setting and displaying cookies in the login code is as follows
Set up native cookie information
$set _info = $record [1]. "|". $record [3]; The record is the result of querying from the database, which is no problem
Setcookie ("UserInfo", $set _info, Time () +60*60*24); Set a native cookie
Extracting information from cookies
$PP = Explode ("|", $_cookie[userinfo]); Separate two messages from a cookie
echo $pp [0]. " ----". $pp [1]."
"; Output this information. This is where the problem comes in! The printed thing is empty, nothing, the last line of UserInfo plus double quotation marks are the same.
But it can be shown in the code of the Logout interface.
Read the information in the cookie
echo "The following are the contents of the cookie variable:
";
$PP = Explode ("|", $_cookie["userinfo"]);
echo $pp [0]. " ----". $pp [1]."
"; Here can be very normal to show out!!!!
Releasing cookie variables
Setcookie ("UserInfo", "" ");
This is why AH!!! Is there any other mechanism for cookies? Don't show up when I log in? Ask for answers! PHP ? Cookies
------Solution--------------------
Cookie is visible the next time the page loads
------Solution--------------------
Citation:
OK, suddenly understand ~ ~ ~ The original post will be able to understand the problem .... This is a very stupid question, Daniel, just float through it ~ ~ ~