[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 89
  • Last Modified:

session dropped in IE

I'm testing a php app which we moved to a client's subdomain.   It appears that sessions are being dropped in IE, but are fine in Chrome.  All works fine on my development server (WAMP).

Ran this test.  

<?php
session_start();      
echo "session_ID; ".session_id()."<br>";
echo "cookie:".$_COOKIE['PHPSESSID'];
               
exit();

?>

For Chrome returns initially and the same when reloading.  As it should.
session_ID; 6pgh8t8phal3mgh8koef1ro3f2
cookie:6pgh8t8phal3mgh8koef1

For IE returns initially
session_ID; kjh17obt4o7lsbu54uk5t7d1h4
cookie:

Then on reload returns:
session_ID; q9ge11759b4aa19qs3a9vg9tg5
cookie:

I'm thinking the php.ini session configs need to modified?  session.cookie_domain?

Thanks in advance
0
steveo2
Asked:
steveo2
  • 5
  • 5
1 Solution
 
Ray PaseurCommented:
Please run this on the IE browser and let us know if it works sensibly, thanks.  Please check with Firefox, too.
<?php // demo/session_test.php
/**
 * Demonstrate how PHP sessions work
 *
 * Ref: http://php.net/manual/en/book.session.php
 * Ref: http://php.net/manual/en/function.session-start.php
 * Ref: http://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html
 */
error_reporting(E_ALL);

// 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 (!isset($_SESSION["counter"])) $_SESSION["counter"] = 0;

// SEE IF THE INCREMENT SUBMIT BUTTON WAS CLICKED
if (isset($_POST['bump']))
{
    // ADD ONE TO THE COUNTER
    $_SESSION['counter']++;
}

// SEE IF THE DECREMENT SUBMIT BUTTON WAS CLICKED
if (isset($_POST['dump']))
{
    // TAKE ONE FROM THE COUNTER
    $_SESSION['counter']--;
}

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


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

echo $form;

Open in new window

This article may be helpful...
http://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html
0
 
Ray PaseurCommented:
Is there any chance that you used something like http://domain in one test and http://www.domain in another test?

I installed this script on my server here:
https://iconoun.com/demo/temp_steve.php
<?php // demo/temp_steve.php
/**
 * https://www.experts-exchange.com/questions/28983200/session-dropped-in-IE.html
 */
session_start();
echo "session_ID; ".session_id()."<br>";
echo "cookie:".$_COOKIE['PHPSESSID'];
exit();

Open in new window

When tested initially in IE, it displayed this, which makes sense because the session cookie does not exist at the time of the initial page load:
session_ID; 8f0c3e1be0a5c0bb17bebe57ce458ced
cookie:

After refresh, we got this:
session_ID; 8f0c3e1be0a5c0bb17bebe57ce458ced
cookie:8f0c3e1be0a5c0bb17bebe57ce458ced

Identical results were received on Chrome and Firefox.

Here are my settings for the session, as reported in phpinfo():
Session settings
0
 
steveo2Author Commented:
It worked in both IE and Chrome.
1
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ray PaseurCommented:
That's good -- it means the PHP side of the session is working OK.  Can you please post a link to the URL that has the hiccup on IE?  Thanks.
0
 
steveo2Author Commented:
here is the test on client server:  

0
 
steveo2Author Commented:
0
 
Ray PaseurCommented:
It worked correctly for me on Chrome, where I always accept cookies.  Of course, it did not work correctly on Firefox, where I always deny cookies.  Maybe check your browser cookie settings?
0
 
steveo2Author Commented:
here's the test on my dev site. one site at localhost. Works fine in IE..  I;m thinking is the domain path on the clients server?

dev_test
0
 
Ray PaseurCommented:
Same experience (now shown with XDebug on the server).  Fails if my browser does not accept and return cookies.  Works if the browser accepts and returns cookies.

Two HTTP requests
0
 
steveo2Author Commented:
Thus works from my server but not from clients.  I'll look into the their php.ini settings.

Thanks for your help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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