Cookie session versus other types of cookies

In Internet Explorer, for example, you can enable first-party cookies, third-party cookies, and allow session cookies.

I know the difference between:

  • first cookie is a third party cookie and
  • PHP session and cookie.

But what is a session cookie? And how can you install it using PHP?

For example, you cannot log in to Facebook without the cookie enabled. However, if you allow session cookies, you can log in to Facebook.

So how is a session cookie different from other cookies?

+6
source share
4 answers

A cookie has a lifetime after which it expires (as specified in the Expires directive). If you do not set a timeout, the browser closes the cookie when you close the browser. This is called a session cookie.

These cookies are often used to track the current state of a user session on the server side (for example, php sessions), but there is no strong connection between the two uses of the word β€œsession”

+5
source

A session cookie contains a unique identifier that PHP generates when calling session_start() , so that each client can be associated with a session, and neither of the two sessions can have the same identifier at the same time.

A session cookie is usually destroyed when the browser window is closed, or can be done manually using session_destroy() .

+3
source

From Wikipedia :

Old definition: (2011-12-17)

A session cookie is created when the Expires directive is not provided, when a cookie is created.

Last definition:

Session cookies, also known as in-memory cookies or transient cookies, exist only in temporary memory when a user moves a website. [18] Web browsers typically delete session cookies when the user closes the browser. [19] Unlike other cookies, session cookies do not have an expiration date, that is, how the browser knows how to process session cookies.

+2
source

In PHP, when you use session_start() , it creates a session, this will create a session cookie in the client browser, PHP needs a client to send this information with every request so that PHP can determine the session identifier.

+1
source

Source: https://habr.com/ru/post/903990/


All Articles