php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33814 Remove sess_* files while session_start(); is active
Submitted: 2005-07-22 06:44 UTC Modified: 2005-07-22 10:01 UTC
From: d43m0n at shaw dot ca Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.4 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: d43m0n at shaw dot ca
New email:
PHP Version: OS:

 

 [2005-07-22 06:44 UTC] d43m0n at shaw dot ca
Description:
------------
Hello,

In short, while a session is in progress, or running, we are not able to remove sess_* files by using unlink(). Yet, when a session is not active, I can remove all the files freely. There is nothing about this in the documentation, and there seems to be this issue all over forums searched from google. I feel this is a bug, as PHP should deny removing files while a session is active.

The following produces this error "Warning: unlink(./tmp/sess_2b8185697c7b9d826773403c1477041f) [function.unlink]: Permission denied in X:\path\to\script.php on line 0"

<?php
  define("_PATH_TMP", "X:/dir/to/my/tmp");
  ini_set('session.save_path', _PATH_TMP);
  session_start(); 
  $_SESSION['sid']['obsolete'] = session_id();
  session_regenerate_id();
  $_SESSION['sid']['replaced'] = session_id();
  unlink('./tmp/' . $_SESSION['sid']['obsolete'])
  print_r($_SESSION);
?>

As well, the garbage collection doesnt seem to be working, all I see is my sessions keep piling up since I have my script regenerate an id, thus create a new file in my defined tmp directory. If session_set_cookie_params worked properally, I would beable to define both id's thus to say I could unlink the file with $_COOKIE['sid']['obsolete'].

As well, as I read apon session_regenerate_id() its suppose to remove the file apon complition... well, in short, its not!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-22 10:01 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PHP opens a session file at the start of your script, and Windows does not allow you to unlink an opened file, which is perfectly fine to do on Unices. If you use session_write_close() before the unlink it will work, as that function stops the session during a script.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 09:01:33 2024 UTC