Search⌘ K
AI Features

Session Files and Serialized Data

Explore how PHP session data is stored in system files and understand the serialization process that converts session variables into storable strings. This lesson helps you learn to inspect session contents, use serialize and unserialize functions, and safely debug session data within PHP applications.

We are going to look into a few non-essential details about session storage now. If you don’t think you need to learn about this, skip to the next lesson where we introduce flash messages.

Viewing stored session data

What does stored session data look like? Let’s find out by running php -i | grep session in the Terminal. You should see a list of PHP settings related to sessions:

C++
session
session.auto_start => Off => Off
...
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions

That last value is relevant for us. It says session.save_path, and the value is /var/lib/php/sessions. On your computer, it may be some different directory. Let’s go to that directory:

cd /var/lib/php/sessions`.

See what’s inside this directory by running ls.

Javascript (babel-node)
ls

If you get an error saying “ls: cannot open directory ‘.’: Permission ...