Obtain the cookie value index. phpHTMLcode & lt; iframesrc = & quot; main. php & quot; style = & quot; display: ''& quot; & gt; & lt;/iframe & gt; main. obtain the cookie value using phpPH
Index. php
HTML code
Main. php
PHP code
Setcookie ("l_cookie", "cookie value ");
Why can't I get the cookie value in index. php ????
I directly echo $ _ COOKIE ["l_cookie "]
------ Solution --------------------
Not to mention index. php
That is, main. php does not have this value, unless you assign a value immediately after setcookie
Either assign values in index. php and assign values at the same time, or use js values
------ Solution --------------------
The cookie is saved to the client only after the current request is complete. Therefore, the cookie value set currently cannot be obtained during the request process (the request is incomplete ), only the cookie value set during the last access can be obtained.
As mentioned above, refresh the page to get the cookie set during the first access, which is equivalent to 2nd accesses.