Difference Cookie, Session of

1.Cookie

I.e., the data stored in the client local user, used to identify the user's identity.

If you check the Remember Me Cookie information is saved in the C disk, valid until the expiration Cookie settings

note:

(1) record user visits

(2) non-cross-domain: that in various web browsers to access the Cookie will be stored on different servers

(3) Method: setter, getter method

(4) Validity: can be set by setting properties MaxAge period of validity Cookie, the default is -1 (the browser is closed, Cookie disappear, 0: Delete Cookie, Cookie new)

(5) set the validity period will be persistent Cookie information stored in the local disk C, less secure

2.Session

Stored in the data structure of the server, the client used to check the information, tracking user status, verify that the client's identity.

note:

(1) Session likely to increase pressure on the server, client access server easily lead to a large number of memory overflow

(2)方法:getAttribute,setAttribute

(3) only access JSP, Session will be created

(4) Session id is returned Jsesion id Cookie information

(5) Safety Session higher than Cookie, the browser closes the Session id disappear

Guess you like

Origin www.cnblogs.com/QaStudy/p/11514846.html