Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

session dropped in IE

Posted on 2016-11-15
10
Medium Priority
?
73 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 111

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 111

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
Technology Partners: 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!

 
LVL 111

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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 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