PHP cookie and session problems

Source: Internet
Author: User
PHPcookie and session problems in PHP, what are the advantages of cookie and session in addition to saving the cookie on the client without occupying the server's hard disk? When PHP processes the page, the page is generated on the server before it is sent to the client. if the data is cached in the cookie, it is necessary to first send the data to the client. The next time you access the page, the issue of cookie and session stored in the cook PHP client
In PHP, what are the advantages of cookie compared with session in addition to saving the cookie on the client without occupying the server's hard disk?

When PHP processes the page, the page is generated on the server before it is sent to the client. if the data is cached in the cookie, it is necessary to first send the data to the client. The next time you access the page, then, send the data stored in the client cookie to the server, process the data, and send it back to the client ...... It seems that the process of transmitting data twice is more than that of using session to cache data? (The session is only read on the server, eliminating Network Transmission ?)

I don't know, do you? If this is the case, I feel that I have no advantage in using cookies to cache data ......

Thank you for your patience ~

Thank you!

(Is there a technology that caches data on the client, and the server does not need to read the php file from the client again when processing the php file, but is automatically processed by the client? That is, the server leaves a mark on the place where the data needs to be cached on the page. when the client reads the mark, it loads the cached data ......)


------ Solution --------------------
If you save all the data in the session, of course, the premise is that you have enough memory to support it?

You can use js + cookie for implementation, but there is a problem that the content that can be saved by cookies is limited. In addition, it is easy to forge.
------ Solution --------------------
Cookies are exposed. they are not secure. it hurts the client to write server letters or messages.
COOKIE is a degraded session technology. does it affect the logic and security of the server.

If a user logs on, you send a COOKIE to the user to mark that the user has logged on, it will be finished ..
As long as the bad guys analyze the COOKIE format, they can make it up with any account name ..

Anything that the client can directly touch is insecure.
------ Solution --------------------
So how do you delete deleted records from a large amount of cached data?

In particular, if a database query involves a large number of operations such as union and Cartesian product, the content of the result set may change greatly (the union related to the deleted record and the Cartesian product do not exist.)
------ Solution --------------------
Furthermore, SESSION and COOKIE are private to users.
Deleting a record is a public event. you cannot say that deleting a record is invalid for deleting a record.
Assuming that 10 thousand users are online now, how are you going to update their cache?

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.