Problem Reading session files
| From: | Schulz, Evan | Date: | Thu, 12 Apr 2001 22:11:48 +0000 |
| Subject: | Problem Reading session files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-48367@lists.php.net to get a copy of this message | ||
I am about to pull my hair out trying to figure out why this isn't working.
I figured I would wait and hope that someone else's eyes would pick
something up, though. I am running it on 4.04pl1 CGI / Win 2k / IIS 5. I
am trying to read from the session files that are in C:\php\sessiondata in
order to create an administration script to open up each session file, grab
each username variable that I have registered in it, and print the names to
the screen.
This is the code I have with comments describing what is happening when I
run it:
function show_loggedin_users() {
$loopcounter=0;
if ($dir = opendir('c:/php/sessiondata')) {
while($files = readdir($dir)) {
if (substr($files,0,1) != '.') { //don't want the '.' or
'..' files
$sess_id[$loopcounter]=substr($files, 5); //get the sid from the
filename (removes the sess_ from the filename)
$fullfilepath='c:/php/sessiondata/'.$files;
$fp = fopen($fullfilepath, "r"); //open up the session's file
$fcontents = fread($fp, filesize($fullfilepath)); //get the
contents of the file - it won't, though!
echo $fcontents; //just to check to see if it worked - it doesn't
print anything
fclose($fp);
...
There is a session file in the directory, there are registered variables in
the file, and I can print $fullfilepath and get a correct path and filename
to the file. I also tried fgets instead of fread. Nothing seems to work,
though...
Any corrections/thoughts/comments are appreciated.