You are here: Sessions - Not working with IE « PHP Programming Language « IT news, forums, messages
Sessions - Not working with IE

Posted by Steve Wright on 10/26/06 08:16

Forgive my ignorance, but I am just starting to learn about sessions in
PHP and how to pass data from one page to the next. What I'm about to
explain could just be my misunderstanding of how sessions work.

I have two test scripts. The first starts a session, displays a few
details and a form. When the form is submitted it jumps to the second
page. The first script looks like this.

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Session test : Page 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
</head>
<body>
<ul>
<?php
$_SESSION['session_var'] = "testing";
echo "<li>Your session id is ".session_id()."</li>\n";
echo "<li>The SESSION array contains<br />\n";
print_r($_SESSION);
echo "</li>\n";
echo "<li>The SID is ".SID."</li>\n";
echo "<li>PHPSESSID = ".$PHPSESSID."</li>\n";
?>
</ul>
This is the test of the sessions feature
<form action="session2.php" method="post">
<input type="hidden" name="form_var" value="testing" />
<input type="submit" value="Go to next page" />
</form>
</body>
</html>

The second script displays the same variables as the first. In addition
it dislpays the value of a variable passed by the _$SESSION array and a
value passed via a form. It looks like this.

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Session test : Page 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
</head>
<body>
<ul>
<?php
echo "<li>Your session id is ".session_id()."</li>\n";
echo "<li>The SESSION array contains<br />\n";
print_r($_SESSION);
echo "</li>\n";
echo "<li>The SID is ".SID."</li>\n";
echo "<li>PHPSESSID = ".$PHPSESSID."</li>\n";
echo "<li>session_var = {".$_SESSION['session_var']."}</li>\n";
echo "<li>form_var = {".$_POST['form_var']."}</li>\n";
?>
</ul>
</body>
</html>

When run under IE6, I get the following output.

Script 1

· Your session id is d7e201df8eb6ac9fd76915e53051666d
· The SESSION array contains
Array ( [session_var] => testing )
· The SID is PHPSESSID=d7e201df8eb6ac9fd76915e53051666d
· PHPSESSID =

Script 2

· Your session id is 40211048ab6869c74dc8e9dff6098dc0
· The SESSION array contains
Array ( )
· The SID is PHPSESSID=40211048ab6869c74dc8e9dff6098dc0
· PHPSESSID =
· session_var = {}
· form_var = {testing}

Note how the session id is different and the variable passed by the
_$SESSION array is blank.

When run under Firefox 2.0 I get the following;

· Your session id is 00802b0742fdb87cda553cba85027c30
· The SESSION array contains
Array ( [session_var] => testing )
· The SID is PHPSESSID=00802b0742fdb87cda553cba85027c30
· PHPSESSID =

and

· Your session id is 00802b0742fdb87cda553cba85027c30
· The SESSION array contains
Array ( [session_var] => testing )
· The SID is
· PHPSESSID =
· session_var = {testing}
· form_var = {testing}

This time, the session ids are the same and the variable is passed.

Any ideas why the difference?
With Firefox, why is SID populated on the first page and not the
second?
Why is PHPSESSID blank?

In case it helps, the values from the php.ini file for session are;

session.auto_start = 0
session.cache_expire = 180
session.cache_limiter = nocache
session.cookie_domain =
session.cookie_lifetime = 0
session.cookie_path = /
session.entropy_file =
session.entropy_length = 0
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.name = PHPSESSID
session.referer_check =
session.save_handler = files
session.save_path = /tmp
session.serialize_handler = php
session.use_cookies = 1
session.use_trans_sid = 1

Regards
Steve Wright

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация