Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 389705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:53:35+00:00 2026-05-12T15:53:35+00:00

Session files are usually stored in, say, /tmp/ on the server, and named sess_{session_id}

  • 0

Session files are usually stored in, say, /tmp/ on the server, and named sess_{session_id}. I have been looking at the contents and cannot figure out how they really work.

Fetching the variable name and content from the file is easy. But how does PHP know what session belongs to whom?

The session_id seems totally random and one IP address can have several users, and each user can have several sessions if they have more than one browser window open.

So how does it work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:53:35+00:00Added an answer on May 12, 2026 at 3:53 pm

    In the general situation :

    • the session id is sent to the user when his session is created.
    • it is stored in a cookie (called, by default, PHPSESSID)
    • that cookie is sent by the browser to the server with each request
    • the server (PHP) uses that cookie, containing the session_id, to know which file corresponds to that user.

    The data in the sessions files is the content of $_SESSION, serialized (ie, represented as a string — with a function such as serialize) ; and is un-serialized when the file is loaded by PHP, to populate the $_SESSION array.

    Sometimes, the session id is not stored in a cookie, but sent in URLs, too — but that’s quite rare, nowadays.

    For more informations, you can take a look at the Session Handling section of the manual, that gives some useful informations.

    For instance, there is a page about Passing the Session ID, which explains how the session id is passed from page to page, using a cookie, or in URLs — and which configuration options affect this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The session files are saved at session_save_path().'/sess_'.session_id() . Is 'sess_' hard-coded? If it can
I periodically remove the tmp out of session files. Apparently, I mismanage sessions because
I have over 5 million session files in /var/lib/php5 I would like to delete
On my website I use PHP sessions. Session information is stored in files in
I have a customer who's magento session files are quickly growing out of control.
I keep running into stale, locked, (php) session files on my apache server which
I have an application that has been working with session variables no problem. I
I have created a custom control which uploaded files to the server . These
I have problem with session in cakephp.I have one file chat.php that is in
First of all, I would like to say that I have used the search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.