Solved

session dropped in IE

Posted on 2016-11-15
10
46 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 109

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 109

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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 109

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 109

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 109

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 6 36
Blocking submission of a web-based form 6 20
PHP Query return divisible by 3 3 17
Creating Functions in phpMyAdmin 8 17
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

778 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