1

Let's start a session:

session_start();

A new file is created on session_save_path() folder, e.g. "sess_ovp3r00elb9q07jkb3kthcbhn5".

This file is a 0 bytes empty file.

I know I can remove it at the end of script this way:

if (session_status() == PHP_SESSION_ACTIVE AND !$_SESSION) @session_destroy();

But, why does PHP create this empty file?

Is it possible to change this behaviour and create the file only when a variable is set?

Thanks

EDIT: Duplicate answers have no relation with my question.

  • Why do you care? These files get cleaned up by the garbage collector. There's no reason to worry about them, and no reason to go mucking with the internals. Why are you starting sessions if you're not going to use them? – ceejayoz Oct 13 '17 at 16:52
  • I am just curious. PHP is generating garbage with these empty files. – Playinteractive Oct 13 '17 at 19:54

0 Answers0