Solved

session dropped in IE

Posted on 2016-11-15
10
20 Views
Last Modified: 2016-11-15
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
Comment
Question by:steveo2
  • 5
  • 5
10 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41888194
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41888211
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
 
LVL 2

Author Comment

by:steveo2
ID: 41888227
It worked in both IE and Chrome.
1
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41888241
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
 
LVL 2

Author Comment

by:steveo2
ID: 41888264
here is the test on client server:  

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 2

Author Comment

by:steveo2
ID: 41888266
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41888282
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
 
LVL 2

Author Comment

by:steveo2
ID: 41888308
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41888357
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
 
LVL 2

Author Comment

by:steveo2
ID: 41888369
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now