Strange! About cookies! What should I do?

Source: Internet
Author: User
Strange! About Cookies !! $ Str = 'abc'; on one page, I write: setcookie (& quot; dede_cmp & quot;, $ str); on the other page, write: echo $ _ COOKIE ['dede _ cmp ']; but nothing is output. why ?, PHPcodese is strange! About Cookies !!
$ Str = 'abc ';

On a page, I wrote: setcookie ("dede_cmp", $ str );

Write another page: echo $ _ COOKIE ['dede _ cmp '];

But nothing is output. why?

------ Solution --------------------
PHP code
Setcookie (name, value, expire, path, domain, secure) set the Expiration time // send a cookiesetcookie ("TestCookie", $ value, time () that expires 24 hours a day () + 3600*24 );
------ Solution --------------------
Oh. It is also a disaster caused by 360. Try it in another browser.
------ Solution --------------------
Notice: Undefined index: error?
------ Solution --------------------
Use live http headers or firebug in firefox
"I wrote: setcookie (" dede_cmp ", $ str);" on a page );"
Whether the http headers of this page has the setcookie header
------ Solution --------------------
Do not have any html output before setcookie, such as echo.
It is best to use a separate php page setcookie
------ Solution --------------------
Discussion

Do not have any html output before setcookie, such as echo.
It is best to use a separate php page setcookie

------ Solution --------------------
Print_r ($ _ REQUEST );
Print_r ($ _ COOKIE );
If there is no, there is no. In addition, firefox can directly view cookies.
------ Solution --------------------
Isset () try to see if it is set

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.