• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

$_SESSION Not Working in Internet Explorer

I'm using:

session_start();
$_SESSION['nameOfFile'] = "filename";

--------------------

Works in Firefox but not in IE.

Any ideas how to make this work in both?
0
deharvy
Asked:
deharvy
  • 2
  • 2
1 Solution
 
bartvdCommented:
This works perfectly in both IE and FF.
I think the problem is not in the code, but in your browser cache or something.
0
 
Ray PaseurCommented:
Check and make sure you don't have some odd setting like "Work Offline" in IE.  Then install this and run it to see if the cheese counter goes up.  Or just test here at my server:
http://www.laprbass.com/RAY_session_test.php
<?php // RAY_session_test.php
error_reporting(E_ALL);


// DEMONSTRATE HOW PHP SESSIONS WORK
// MAN PAGE HERE: http://us.php.net/manual/en/function.session-start.php


// START THE SESSION (DO THIS FIRST, UNCONDITIONALLY, IN EVERY PHP SCRIPT ON EVERY PAGE)
session_start();

// INITIALIZE THE SESSION ARRAY TO SET A DEFAULT VALUE
if (empty($_SESSION["cheese"])) $_SESSION["cheese"] = 1;

// SEE IF THE CORRECT SUBMIT BUTTON WAS CLICKED
if (isset($_POST['fred']))
{
    // ADD ONE TO THE CHEESE
    $_SESSION['cheese']++;
}

// RECOVER THE CURRENT VALUE FROM THE SESSION ARRAY
$cheese = $_SESSION['cheese'];


// END OF PROCESSING SCRIPT - CREATE THE FORM USING HEREDOC NOTATION
$form = <<<ENDFORM
<html>
<head>
<title>Session Test</title>
</head>
<body>
Currently, SESSION["cheese"] contains: $cheese<br/>
<form method="post">
<input type="submit" value="increment this cheese" name="fred"  />
<input type="submit" value="leave my cheese alone" name="john" />
</form>
</body>
</html>
ENDFORM;

echo $form;

Open in new window

0
 
Ray PaseurCommented:
Another thought - make sure your settings allow your browser to return cookies, since they are all but required to use the internet today.
0
 
deharvyAuthor Commented:
Correct. Now I know that sessions are based on cookies.

To resolve this, go to Internet Explorer, Tools, Internet Options, Privacy Tab, Sites.

There you can list the domain names that you want to authorize the use of cookies.

Works like a charm.
0
 
deharvyAuthor Commented:
Ray,

Didn't see your response till late. Thanks for the sample PHP. I will use this going forward to test any issues with $_Sessions.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now