How Session works in PHP

Session is a way to store information (in variables) to be used across multiple pages. We can see the architecture of session workflow below:

  • Initially we need to write the command session_start() to start a session.
  • Once we write the command server will check if there is a session available.
  • If there is no server then it will store a cookie in the client machine with the cookie name – PHPSESSID amd it will create a session id of 26 or 32 characters.
  • With that it will also store a file on server (Default Location – C:\xampp\tmp) with session id in the suffix.
  • If there is already a session in the client machine then it will show the variables stored in the session under (C:\xampp\tmp) the server.
  • Once we close the browser all the session ends.

Reference:

Joydeep M
Latest posts by Joydeep M (see all)
Tagged : /
5 1 vote
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] How Session works in PHP […]

1
0
Would love your thoughts, please comment.x
()
x