How To Understand Cookie And Session(I)

Session For PHP

When you operate an application on a computer, you open it, make changes, and then close it. It is like a conversation. Because the HTTP address cannot be maintained, the Web server does not know who you are and what you have done. PHP session solves this problem by storing user information on the server for subsequent use (such as user name, purchase goods, etc.). However, session information is temporary and will be deleted after the user leaves the site. If you need to store information permanently, you can store data in a database. When a user jumps between Web pages of an application, the variables stored in the Session object will not be lost, but will persist throughout the user session. There is a certain relationship between the implementation of Session and Cookie. Setting up a connection generates a session ID and opening several pages. Cookie is used here. The Session ID is stored in the Cookie. Session ID can be recognized by taking it with you every time you visit it.Steel Pipe Suppliers

Difference between Cookie and Session

Data storage: session can store arbitrary Java objects, cookies can only store String type objects.

One is on the client side and the other is on the server side. Because Cookie is on the client side, it is not very safe to edit forgery.

Server resources will be consumed when Session is too much. Large websites will have special Session servers. Cookie has no problem with clients.

Domain support ranges are different. For example, Cookie of a.com can be used under a.com, while Session of www.a.com can not be used under api.a.com. The solution to this problem is JSONP or cross-domain resource sharing.

Leave your comment