What are the differences between php cookies and sessions?

藏色散人
Release: 2023-03-01 18:16:01
Original
2729 people have browsed it

The difference between cookie and session is: 1. Cookie is a mechanism that stores data on the remote browser side and uses it to track and identify users, while session is used in PHP to keep users continuously accessing web applications. Relevant data; 2. Cookies are not very safe, but sessions are relatively safe.

What are the differences between php cookies and sessions?

Cookie and Session

Cookie: PHP transparently supports HTTP cookies. Cookie is a mechanism that stores data on the remote browser side and uses it to track and identify users

Session: The session mechanism (Session) is used in PHP to maintain relevant data when users continuously access web applications

The difference between php cookie and session

1. Cookie data is stored on the client's browser, and session data is placed on the server.

2. Cookies are not very safe. Others can analyze the COOKIE stored locally and deceive COOKIE

Considering security, session should be used.

3. The session will be saved on the server within a certain period of time. When access increases, it will take up more of your server's performance

In order to reduce server performance, COOKIE should be used.

4. The data saved by a single cookie cannot exceed 4K. Many browsers limit a site to save up to 20 cookies.

5. So personal suggestion:

Store important information such as login information as SESSION

If other information needs to be retained, it can be placed in COOKIE

For details, please visit "PHP cookie" and "PHP session"

The above is the detailed content of What are the differences between php cookies and sessions?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!