SrIl SrIl - 25 days ago 4x
PHP Question

how session works online


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
is called. Does that destroy all session data on the site (even for the second user)?


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