ajax-based login fails: IE6 and IE7 ajax calls delete session data (session_id however is kept)
Posted
by mateipavel
on Stack Overflow
See other posts from Stack Overflow
or by mateipavel
Published on 2010-03-28T11:20:30Z
Indexed on
2010/03/28
11:23 UTC
Read the original article
Hit count: 440
This question comes after two days of testing and debugging, right after the shock I had seeing that none of the websites i build using ajax-based login work in IE<8
The most simplified scenario si this:
1. mypage.php :
session_start();
$_SESSION['mytest'] = 'x';
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript">
function loadit() {
$.post('http://www.mysite.com/myajax.php', {action: 'test'}, function(result){alert(result);}, 'html');
}
</script>
<a href="javascript:void(0);" onclick="loadit(); return false;">test link</a>
2. myajax.php
session_start();
print_r($_SESSION);
print session_id();
When I click the "test link", the ajax call is made and the result is alert()-ed:
IE6:
weird bullet-character (•)
IE7:
Array(
)
<session_id>
IE8/FF (Expected behaviour):
Array(
[mytest] => 'x'
)
<session_id>
I would really appreciate some pointers regarding: 1. why this happens 2. how to fix it
Thank you.
© Stack Overflow or respective owner