Php simple cookie problems ~~ Make a simple website login interface and logout interface, and set the cookie in the php code on the login interface. if you want to display it in this program, it cannot be displayed, the code on the logout page is displayed. The code for setting and displaying cookies in the login code is as follows // you can set the cookie information of the local machine $ set_info & nbsp php for simple Cookie problems ~~
Make a simple website login interface and logout interface, and set the cookie in the php code on the login interface. if you want to display it in this program, it cannot be displayed, the code on the logout page is displayed.
The code for setting and displaying cookies in the logon code is as follows:
// Set local Cookie information
$ Set_info = $ record [1]. "|". $ record [3]; // record is the query result from the database. this is correct.
Setcookie ("userinfo", $ set_info, time () + 60*60*24); // set the local cookie
// Extract information from cookies
$ Pp = explode ("|", $ _ COOKIE [userinfo]); // Extract two pieces of information from the cookie.
Echo $ pp [0]. "----". $ pp [1]."
"; // Output this information. This is where the problem occurs! The printed items are empty and nothing exists. the userinfo of the last line is added with single quotation marks without double quotation marks.
But it can be displayed in the code of the logout interface.
// Read the information in the Cookie
Echo "the following is the content of the Cookie variable:
";
$ Pp = explode ("|", $ _ COOKIE ["userinfo"]);
Echo $ pp [0]. "----". $ pp [1]."
"; // It can be displayed normally !!!!
// Release the Cookie variable
Setcookie ("userinfo ","");
Why !!! Is there any other mechanism for cookie? Why is it not displayed during login? Please answer! Php? Cookie
------ Solution --------------------
The cookie is visible only when the next page is loaded
------ Solution --------------------
Reference:
Okay, I suddenly understood it ~~~~ It turns out that you can understand the problem after posting .... This is an idiot ~ Let's see you here ~~~~