Session variable is empty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
venkyphp
Forum Newbie
Posts: 2
Joined: Tue Dec 22, 2009 11:16 pm

Session variable is empty

Post by venkyphp »

When i am using session variable for my application it is working fine for IE but when it comes to FireFox it is becoming empty..it is a critical issue..anyone can help me..plzzz..
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Session variable is empty

Post by Christopher »

Are you doing a redirect on the page? If so you may need to call the session function to save the session data, because both pages are in a single request.
(#10850)
venkyphp
Forum Newbie
Posts: 2
Joined: Tue Dec 22, 2009 11:16 pm

Re: Session variable is empty

Post by venkyphp »

No..not redirecting to the same page..i am just loading the image and adding the prefix to the image name by the session variable.. it is working fine in ie but not in FF..plz... suggest me the solution to this issue...
imran.rajani
Forum Newbie
Posts: 16
Joined: Tue Dec 22, 2009 5:34 pm

Re: Session variable is empty

Post by imran.rajani »

you might be using session_register().
i've noticed this is not compatible with FF.
pjcvijay
Forum Commoner
Posts: 25
Joined: Tue Sep 09, 2008 6:12 am

Re: Session variable is empty

Post by pjcvijay »

Hi,

session_start(); function should be called at the beginning of the php file, before retrieve or save session data.

session_write.php
<?php
session_start();
$_SESSION['user_name'] = 'Admin';
?>

session_read.php
<?php
session_start();
echo 'Current User: ' . $_SESSION['user_name'];
?>
Post Reply