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)?
Asked
Active
Viewed 37 times
0
-
I would look into `session_unset()` also http://php.net/manual/en/function.session-unset.php and going through **User Contributed Notes.** – Funk Forty Niner Sep 30 '16 at 00:06
2 Answers
1
A 'session` is by definition per user, so no, Destroying a session for user 1 has no affect on user 2

Duane Lortie
- 1,285
- 1
- 12
- 16
1
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

Vural
- 8,666
- 11
- 40
- 57