Jump to content

[SOLVED] $_COOKIE or $_SESSION won't go into new window in FireFox? HELP!! Urgent.


Recommended Posts

Ok. I have a problem. I have one page, with both a session and a cookie set, and they work when I do if's.

 

When I open a new window, $_COOKIE and $_SESSION start acting wierd in the IF() test and it doesn't work.. like here:

 

if( $_COOKIE['member_logged'] == false || $_SESSION['member_logged'] = false)

 

If I take out the COOKIE part, the SESSION will pick up that its false. But cookie should be false too but it doesn't even pick it up. Is there something wierd I have to do when opening a new window?

 

However, its wierd because everything works in Internet Explorer.. ?

I am running it.. I checked like everything ughh this is so frustrating.

 

It works seamlessly in Internet Explorer 7, but in FireFox, either the cookie is False or the session is False, yet I know they are both true.

OK.. Here is the code to create cookie/session:

 

setcookie("member_logged",true,time()+21600,"/");
$_SESSION['member_logged'] = true;

 

Here is the page code. It should let you post, because you're logged in and its true, but it just says "Please login" as if your not logged in. (This is only in FireFox/Opera).

 

<?php 
if($_COOKIE['member_logged'] == false || $_SESSION['member_logged'] = false)
{
?>
<p/>Please login to post a comment.
<?php
}
else
{
?>
<form action="config/commentadd.php" method="post">
<table width="80%" border="0">
<tr>
<td width="20%">Username:</td>
<td width="80%"><input name="user" type="text" value="<?php echo $user; ?>" size="32" disabled="disabled"></td>
</tr>
<td>Comment:</td>
<td><textarea name="comment" cols="45" rows="5"></textarea> *</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Send!" name="submit"></td>
</tr>
</table>
<input name="id" type="hidden" value="<?php echo $id; ?>" />
</form>
<?php
}
?>

if($_COOKIE['member_logged'] == false || $_SESSION['member_logged'] = false)

 

should be

 

if($_COOKIE['member_logged'] == false || $_SESSION['member_logged'] == false)

 

though I dont know how that would matter what browser it is...

 

are you trying to set cookies and use them in the same page? that could cause a problem...

 

also this script isn't really well formed... what if someone set their member_logged cookie to true?

Did that, I figured it out, don't know why but I just flipped it around like this:

 

<?php if($_SESSION['member_logged'] == true || $_COOKIE['member_logged'] == true){?>
<form action="config/commentadd.php" method="post">
<table width="80%" border="0">
<tr>
<td width="20%">Username:</td>
<td width="80%"><input name="user" type="text" value="<?php echo $_SESSION['profile']['displayname']; ?>" size="32" disabled="disabled"></td>
</tr>
<td>Comment:</td>
<td><textarea name="comment" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Send!" name="submit"></td>
</tr>
</table>
<input name="id" type="hidden" value="<?php echo $id; ?>" />
</form>
<?php } else { ?>
<p/>Please login to post a comment.
<?php } ?>

Maybe the fact that the link is launched by using

 

target="_blank"

 

Might that have something to do with it?

 

take this out and test the page - does it work?

 

I think Firefox is more security conscious of passing cookie information between new windows. Stops evil people stealing your cookie, and session.

 

monk.e.boy

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.