0

I have got an issue which I am 99% sure is related to Internet Explorer (no way!): session variables are not being carried from one file to another (on the same domain). The pages are served by IIS 7.

To simplify the problem-solving process I have created two test files:

test_1.php:

<?php
session_start();
$_SESSION['test'] = '123';
?>
<a href="test_2.php">Go to result</a>

test_2.php:

<?php
session_start();
echo $_SESSION['test'];
session_unset();
?>
<a href="test_1.php">Go to page 1</a>

This works as expected in Chrome 33.0.1750.154 and Firefox 28.0, but in IE9 I get the following error:

Notice: Undefined index: test in D:\test_2.php on line 3

Am I missing something obvious?

Thanks

valoukh
  • 541
  • 1
  • 8
  • 19
  • 3
    Is your copy of IE blocking cookies? – John Conde Apr 08 '14 at 15:50
  • make sure `session_id()` returns the SAME value in both scripts. If you get different values, then your session cookies are set incorrectly and you're getting a different session in each script. – Marc B Apr 08 '14 at 15:50
  • cfr John Conde, a different browser settings (for cookies, security,...) is the only plausible explanation for this. When facing a client problem (difference depending on browser), always look in the client part. What's the client part of sessions ? cookies (most of the time) – Laurent S. Apr 08 '14 at 15:51
  • The IDs are different (in IE only!), so that's a start. We are on a network and all computers (that we've tested) seem to be affected, so it may well be a cookie setting that needs setting globally. Do you have any idea what this might be? Thanks – valoukh Apr 08 '14 at 15:59

1 Answers1

0

I finally realised this issue was due to there being an underscore in the IIS virtual directory/application, with help from this answer.

Community
  • 1
  • 1
valoukh
  • 541
  • 1
  • 8
  • 19