Reputation: 649
I have written two functions setSes()
and getSes()
and here I have written session_start()
.Its wroking for all browser except IE.
function setSes(){
$res=mysql_fetch_assoc(mysql_query("select * from table1 limit 1"));//data from DB
$_SESSION['ses1']=$res['name'];//Its not working .... $res['name']='Raj'
$_SESSION['ses1']="priyabrata";//Its working
}
function getSes(){
session_start();
print"<pre>";
print_r($_SESSION);
}
please get some ideas
Upvotes: 0
Views: 1123
Reputation: 14618
The PHP Session writes a cookie, called PHPSESSID
or something like that. You can change the name in php.ini or with special php functions.
Anyway, the browser must accept cookies for sessions to work. IE (earlier versions, maybe even later) has an enforced security policy, which makes it hard to transmit cookies.
I suggest you read this article, which has a comprehensive study of this exact problem, and solutions.
I've been having this problem a lot with IE. If server timestamp was incorrect, or other server settings looked "fishy" to the cookie filter, the cookie was not accepted. Of course most of these security settings can be changed and turned off in IE, but it would have to be done on the client side, which isn't appropriate.
Upvotes: 1
Reputation: 64399
Your code implies that you use getSes()
to get some value from your session, and setSes()
if you want to set it. Now logically, you would set a value before you can get it, right?
But with this code, you would not have called session_start()
while setting your var.
Call session_start()
first thing in your script, and it might go over better....
Upvotes: 0
Reputation: 1930
You need to start the session first Before you set the variables. You may be doing this but in the code you linked you don't show what order getSes() or setSes() is called and you appear to be editing it on the fly so I can't really keep up.
Read up on the start session function here.
http://php.net/manual/en/function.session-start.php
Upvotes: 1