SrIl SrIl - 2 months ago 13
PHP Question

how session works online

Does

session_destroy()
affect different users?
Imagine a situation where there are two users on the same site and the first one gets to the point in the code where
session_destroy()
is called. Does that destroy all session data on the site (even for the second user)?

Answer

session_destroy() will only affect one user with this session.

a Quick explanation how session works for a user.

A session is a way to store information (in variables) to be used across multiple pages.

Unlike a cookie, the information is not stored on the users computer.

When a session is started following things happen

  • PHP first creates a unique identifier (a random string of 32 hexadecimal numbers)
  • A cookie called PHPSESSID is automatically sent to the user's computer to store unique session identification string.
  • A file is automatically created on the server in the designated temporary directory and bears the name of the unique identifier

and a session ends when the user loses the browser or after leaving the page.

For more information see: session