Solved

session dropped in IE

Posted on 2016-11-15
10
57 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 110

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 110

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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 110

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
 
LVL 2

Author Comment

by:steveo2
ID: 41888266
0
 
LVL 110

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 110

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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