What is the difference between setcookie () and $ _SESSION with session.use_only_cookies?

We can send multiple cookies to the visitor’s browser setcookie(). When determining the value using $_SESSION['value']when using, the session.use_only_cookiessession will be stored only in visitors' browsers. What is the difference between these two cases?

EDIT: Obviously, they are mostly different. I just meant the difference in their application. We can set a value on the client side, which can be restored at any time (before the deadline) with equal $ _COOKIE or $ _SESSION; for example, to identify a returning visitor.

+5
source share
3 answers

The cookie is stored on the client side (that is, "inside" the client / browser). _SESSION is serialized and then stored on the server. This data is associated with a session identifier. For instance. when using the file system session handler, the default file name reflects the session identifier. The client (or your script) must provide this session identifier in subsequent requests so that php session management can / reload the session data. One of them is the use of cookies. session.use_only_cookies=Onallows the php session engine to search only session identifiers in cookies.

+5
source

, session.use_only_cookies, . .

:

  • cookie
  • URL- ( GET, PHPSESSID =...)

session.use_only_cookies URL- , cookie.

+6

:

  • setcookie() cookie , cookie . cookie , session_start().
  • $_SESSION[] / / .
  • session.use_only_cookies , cookie, , , URL-.
+5

All Articles