virtuexru Posted March 29, 2007 Share Posted March 29, 2007 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.. ? Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 29, 2007 Share Posted March 29, 2007 do a print_r( $_COOKIE ) and show us what is in it. Obviously do this in firefox monk.e.boy Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 Array ( [phpSESSID] => cd7a2029b67f1c574acfaac256aa5895 ) ?? That's probably bad. Quote Link to comment Share on other sites More sharing options...
per1os Posted March 29, 2007 Share Posted March 29, 2007 No thats probably good, it means your session is still kickin. Make sure you are running session_start(); at the very top of the page. Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 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. Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 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 } ?> Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 Maybe the fact that the link is launched by using target="_blank" Might that have something to do with it? Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 Anyone?!?! Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 Please:(? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted March 29, 2007 Share Posted March 29, 2007 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? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted March 29, 2007 Share Posted March 29, 2007 you need to have <?php session_start(); ?> at the start of you php code Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 29, 2007 Author Share Posted March 29, 2007 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 } ?> Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 30, 2007 Share Posted March 30, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.