PHP Simple Cookie about the problem ~

Source: Internet
Author: User
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 ~ ~ ~
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.