Beffic Posted November 23, 2008 Share Posted November 23, 2008 Okay so I added a javascript function to make my like easier by opening a new window with the following code. <Script Language="JavaScript"> function SomeCommand() { var load = window.open('URL','','scrollbars=yes,menubar=no,height=400,width=300,resizable=yes,toolbar=no,location=no,status=no'); } </Script> <a href=javascript:SomeCommand()></a> Now the java code seems to work and all but when I open the file it doesn't seem to find the cookie in the window mode. But when I open the same file in the browser it finds the cookie and I can proceed. Without the cookie I cannot because it's a login cookie. So is there any idea why it wont read the cookie in window mode but it will in browser? Here is what the cookie is doing. Just in case you are curious. And I know sessions are better but that is not what I am asking for. Thanks. <?php if(!isset($_COOKIE['USER_ID'])) die('Not logged in, please <a href=index.php>go back</a>'); ?> Link to comment https://forums.phpfreaks.com/topic/133917-cookies-please/ Share on other sites More sharing options...
Beffic Posted November 24, 2008 Author Share Posted November 24, 2008 I only posted it here because the only place the cookies aren't being read from is when I have it in the java frame. Link to comment https://forums.phpfreaks.com/topic/133917-cookies-please/#findComment-697329 Share on other sites More sharing options...
xtopolis Posted November 24, 2008 Share Posted November 24, 2008 Show us your setcookie code Link to comment https://forums.phpfreaks.com/topic/133917-cookies-please/#findComment-697342 Share on other sites More sharing options...
Beffic Posted November 24, 2008 Author Share Posted November 24, 2008 setcookie('USER_ID',$Result2['ID'],time()+60*60*24); Link to comment https://forums.phpfreaks.com/topic/133917-cookies-please/#findComment-697947 Share on other sites More sharing options...
xtopolis Posted November 24, 2008 Share Posted November 24, 2008 Well, it seems you're setting the cookie with PHP. Do you have the cookie set to httponly? None of that should matter.. it seems like you're reading it with php as well.. This example works for me: test.html <html> <head> </head> <body> <script type="text/javascript"> function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } setCookie('USER_ID','1','1'); function SomeCommand() { var load = window.open('test.php','','scrollbars=yes,menubar=no,height=400,width=300,resizable=yes,toolbar=no,location=no,status=no'); } </script> <a href="javascript:SomeCommand();">a</a> </div> </body> </html> test.php <?php print_r($_COOKIE); ?> If you're still having trouble, you need to be more clear about what's wrong.. Link to comment https://forums.phpfreaks.com/topic/133917-cookies-please/#findComment-697969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.