tclogo



HotelsCombined.com

Pages

Archives

Categories


Recent Postings

Recent Comments

Feeds

RSS2 feed

Links

Most Popular Posts

The issue of empty session files

Sunday, 28th May 2006 7:20am
After installing Php everything looked like working fine until I tried to use sessions. The sessions did not work and I looked at the php.ini file and the session.save_path was clearly set to an existing folder with read/write permissions. So I checked that folder were sessions were supposed to be saved and I realised that there were two session files and one contained the correct session data and the other was empty and this clearly showed that sessions were not working.


I wrote two small scripts to test:
//first.php
<?php
session_start();
$_SESSION["session_test"] = "session testing";
print $_SESSION["session_test"]."<br>";
print '<a href = "second.php">Second Page</a><br>';
print session_id();
?>


If sessions are working properly then the session id should be the same in both pages and that offers a very simple test apart from the fact that the test string should also be shown in the second page.


The second page script looks like this:
//second.php
<?php
session_start();
print $_SESSION["session_test"]."<br>";
print session_id();
?>


On clicking the link to the second page, the second page had a different session id and the the test string never showed but instead I got this warning : Notice: Undefined index: session_test in C:\webroot\second.php on line 3. (after enabling all errors and warning to show).


After hours of toiling I found out that this issue was caused by the Zone Alarm firewall. I disabled the firewall and the sessions started working. I have looked through the firewall log and I cant see exactly where localhost or PHPSESSID is blocked and so for now I will temporarily disable the firewall when testing script involving sessions and if I cant find a solution then it could be time to move to another firewall.

Post a comment:

 

(required)

(required, but not published)

(optional)





Notify me of follow-up comments via e-mail