Why is there a strange serialize method in the session of PHP?

Source: Internet
Author: User
I always thought that the PHP session was stored in a standard serialize format, and then I tried unserialize to use it to find out that it was another serialization, just like the following

login_ok|b:1;nome|s:4:"sica";inteiro|i:34;

So the question comes, since PHP own a set of Serialize method, and the efficiency is quite high, why in the session also to engage in another unwinnable method?

Reply content:

I always thought that the PHP session was stored in a standard serialize format, and then I tried unserialize to use it to find out that it was another serialization, just like the following

login_ok|b:1;nome|s:4:"sica";inteiro|i:34;

So the question comes, since PHP own a set of Serialize method, and the efficiency is quite high, why in the session also to engage in another unwinnable method?

The encapsulated session should be read with the session, trying to solve its original code is very dirty, the PHP development team should not consider similar requirements.

Second, the serialize is not fast, and the code is huge, because it supports the serialization of objects, __sleep magic methods, and does not match the scenes stored in the session.

  • 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.