Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you help me locate PHP session files?

Tags:

php

session

I have a default configuration of xampp (LAMP) on a windows system, I have been googleing and reading stackflow for an hour but I can not find where php session data is saved, I would like to locate a session file and look at it.

Some sites say windows usually stores it here C:\windows\tmp\ but I was unable to find it there or anywhere else.

  1. Do you know where sessions are saved by default?f
  2. Do you know what kind name and file? extension they might would have?
like image 367
JasonDavis Avatar asked Jul 28 '09 23:07

JasonDavis


People also ask

Where are PHP session files stored?

PHP Session Start By default, session data is stored in the server's /tmp directory in files that are named sess_ followed by a unique alphanumeric string (the session identifier).

How can I access session file in PHP?

Start a PHP Session A session is started with the session_start() function. Session variables are set with the PHP global variable: $_SESSION.

Where are session details stored?

A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Whenever a session is created, a cookie containing the unique session id is stored on the user's computer and returned with every request to the server.

What is PHP session path?

PHP - session_save_path() Function Sessions or session handling is a way to make the data available across various pages of a web application. The session_save_path() is used to set or retrieve the path where the current session data is saved.


2 Answers

session_save_path() - they have no extension, they are long string UID named files.

like image 118
Byron Whitlock Avatar answered Oct 22 '22 12:10

Byron Whitlock


To find the "for sure" location, do the following:

  1. Boot up a cmd prompt
    • Run php --ini and find the loaded configuration file
    • Open the config file and search for 'session.save_path'

That's the path your session files should be saved to.

This assumes that session.save_handler is set to 'files', of course, and isn't overridden anywhere in your code.

By default, it's probably "C:\WINDOWS\Temp". The filenames are generally prefixed with sess_, and do not have an extension.

Edit: Other posters are correct in using session_save_path() to find the path as well. That's probably a more foolproof method, in case there's differences between your CLI configuration and your web configuration. I'll hand out some +1's. :D

like image 10
zombat Avatar answered Oct 22 '22 14:10

zombat