Why is there no output in the reverse sequence?

Source: Internet
Author: User
{Code...}: Why is the above statement not output, that is, why does deserialization fail?
$ Tmp = array ("zh" => ""); setcookie ("zh", serialize ($ tmp); $ g = $ _ COOKIE ["zh"]; echo unserialize ($ g );

Excuse me, why is there no output in the above statements, that is, why does deserialization fail?

Reply content:
$ Tmp = array ("zh" => ""); setcookie ("zh", serialize ($ tmp); $ g = $ _ COOKIE ["zh"]; echo unserialize ($ g );

Excuse me, why is there no output in the above statements, that is, why does deserialization fail?

Thank you.
The Code contains syntax errors,unserializeThe deserialization is followed by an array, whileechoArrays have only syntax errors.
Notice: Array to string conversion
Have you modified the error severity levelnoticeThe error level is blocked, so no object is output.

For how to run cookies, refer to other people's answers.

Echo unserialize ($ g) ['zh '];

Either you dump (unserialize ($ g ))

Set_cookie: a cookie is generated only when the browser sends a response, that is, the next request is shown in $ _ COOKIE.

Deserialization does not fail because the cookie is accompanied by an http request header to access the server. Currently, the cookie value can be printed only when the next page is accessed. So you cannot print it out.

$ _ COOKIE can be obtained only after an HTTP/HTTPS request. $ _ COOKIE ["zh"] is empty now, and of course no content is available.

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.