Jump to content

Recommended Posts

Here is a peculiar problem that I am encountering

This problem is ONLY IN FIREFOX and NOT IN IE (Important !)

I have two pages page1.php, page2.php

Here are the exerpts from the two files.

[b]page1.php :[/b]
session_start();
session_register("username_session");
session_register("fullname_session");
$_SESSION["username_session"]=<value from database>
$_SESSION["fullname_session"]=<value from database>

There is also a form for uploading 5 files (MAX_FILE_SIZE is mentioned as a hidden field with 1000000 as the value)

[b]page2.php :[/b]
session_start();
echo $_SESSION["username_session"]."<BR>";
echo $_SESSION["fullname_session"];
echo $_SESSION["session_variable_created_in_earlier_page"];

The file info posted from the previous page is available here, and also the session variable created on another previous page, but not the session variables created and assigned in page1.php.

The observation: Session variables created on the same page where a file upload form resides, vanish in the next page. This is observed only in firefox and not internet explorer. In IE everything is just fine.

Has any one come across this problem ?
i suppose it all depends on where your session_start(); is in each file.

You cannot access $_SESSION[] from inside seperate <?php ?> tags. For example:

<?php
session_start();
$_SESSION['name'] = 'bob';
echo $_SESSION['name']; <--- WILL DISPLAY
?>
<?php
echo $_SESSION['name']; <--- WILL NOT DISPLAY
?>

As you can see, you cannot take the value of $_SESSION['name'] in the second section as session_start() is not in the same <?php ?> as the echo command.

I hope this makes sense
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
session_start();
$_SESSION['name'] = 'bob';
echo $_SESSION['name']; //<--- WILL DISPLAY
?>
<?php
echo $_SESSION['name']; //<--- WILL NOT DISPLAY
?>[/quote]

You are wrong, the code above displayed bobbob for me, both locally and remotely(IE and firefox).

If what you said was true, why even have sessions?

The key to sessions is to start them correctly on every page. Most people with session issues fail to do that.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.