SrIl SrIl - 11 months ago 58
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)?

Answer Source

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