frames and cookies

This is a discussion on frames and cookies within the PHP Language forums, part of the PHP Programming Forums category; I have a page, which writes a cookie, creating two frames. I have verified via Fireplug that the cookie is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007
R. Vince
 
Posts: n/a
Default frames and cookies

I have a page, which writes a cookie, creating two frames. I have verified
via Fireplug that the cookie is being written. In one of the frames, an
attempt then is made to read the cookie. Therein, I have code to see if the
cookie is set -- and it keeps telling me it is not set (despite my being
able to see it there, and it;s contents, and it is correct). Can someone
please tell me why, in this code, my frame connot read this cookie? Thanks.

//here is the page that creates the cookie, and establishes the frames
-------------------------------
<?php
$user= $_POST['user'];
$server= $_POST['server'];
$port= $_POST['port'];
$channel= $_POST['channel'];
$email= $_POST['email'];
$fullname= $_POST['fullname'];
$sk= $_POST['sk'];
$voice= $_POST['voice'];
$usevoice= $_POST['usevoice'];
$password= $_POST['password'];
$timer = md5(time());
$info = $user . "+" . $server . "+" . $port. "+" . $channel. "+"
..$email. "+" .$fullname. "+" .$sk. "+" .$voice. "+" .$usevoice. "+"
..$password;
SetCookie("vios", $info, time() + 86400 * 10); //Set Cookie for 10
days
?>
<HTML>
<HEAD>
<TITLE>VIOS Demonstration</TITLE>
</HEAD>

<frameset rows="320,*">
<!--<frame src="ggadmintop.html" name="main" marginwidth="1"
marginheight="1"> -->
<frame src="viostop.php" name="top" scrolling="no" noresize
FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" marginwidth="1"
marginheight="1">
<?php
echo "<frame
src=\"http://127.0.0.1:2001?userid=".$user."&password=".$passwo rd."
name=\"bottom\" marginwidth=\"1\" scrolling=\"no\" noresize
FRAMEBORDER=\"0\" BORDER=\"0\" FRAMESPACING=\"0\" marginheight=\"1\">";
?>
<noframes>
<body>
<p>
<p>This web page uses frames, but your
browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</HTML>
-------------------------------------------------------------
//and here is the frame that attempts to then read the cookie:

<html>
<head>
</head>
<body>
<?php
if (!(isset($vios))) {
echo "cookie not set in browser.";
exit;
}
$sidarray = explode("+", "$vios");
$user= $sidarray[0];
$server= $sidarray[1];
$port= $sidarray[2];
$channel= $sidarray[3];
$email= $sidarray[4];
$fullname=$sidarray[5];
$sk= $sidarray[6];
$voice= $sidarray[7];
$usevoice= $sidarray[8];
$password= $sidarray[9];
?>


Reply With Quote
  #2 (permalink)  
Old 03-27-2007
Erwin Moller
 
Posts: n/a
Default Re: frames and cookies

"R. Vince" <rvince99 a t hotmail d o t com> wrote:

> I have a page, which writes a cookie, creating two frames. I have verified
> via Fireplug that the cookie is being written. In one of the frames, an
> attempt then is made to read the cookie. Therein, I have code to see if
> the cookie is set -- and it keeps telling me it is not set (despite my
> being able to see it there, and it;s contents, and it is correct). Can
> someone please tell me why, in this code, my frame connot read this
> cookie? Thanks.
>
> //here is the page that creates the cookie, and establishes the frames
> -------------------------------
> <?php
> $user= $_POST['user'];
> $server= $_POST['server'];
> $port= $_POST['port'];
> $channel= $_POST['channel'];
> $email= $_POST['email'];
> $fullname= $_POST['fullname'];
> $sk= $_POST['sk'];
> $voice= $_POST['voice'];
> $usevoice= $_POST['usevoice'];
> $password= $_POST['password'];
> $timer = md5(time());
> $info = $user . "+" . $server . "+" . $port. "+" . $channel. "+"
> .$email. "+" .$fullname. "+" .$sk. "+" .$voice. "+" .$usevoice. "+"
> .$password;
> SetCookie("vios", $info, time() + 86400 * 10); //Set Cookie for 10
> days
> ?>
> <HTML>
> <HEAD>
> <TITLE>VIOS Demonstration</TITLE>
> </HEAD>
>
> <frameset rows="320,*">
> <!--<frame src="ggadmintop.html" name="main"
> marginwidth="1"
> marginheight="1"> -->
> <frame src="viostop.php" name="top" scrolling="no"
> noresize
> FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" marginwidth="1"
> marginheight="1">
> <?php
> echo "<frame
> src=\"http://127.0.0.1:2001?userid=".$user."&password=".$passwo rd."
> name=\"bottom\" marginwidth=\"1\" scrolling=\"no\" noresize
> FRAMEBORDER=\"0\" BORDER=\"0\" FRAMESPACING=\"0\" marginheight=\"1\">";
> ?>
> <noframes>
> <body>
> <p>
> <p>This web page uses frames, but your
> browser doesn't support them.</p>
> </body>
> </noframes>
> </frameset>
> </HTML>
> -------------------------------------------------------------
> //and here is the frame that attempts to then read the cookie:
>
> <html>
> <head>
> </head>
> <body>
> <?php
> if (!(isset($vios))) {
> echo "cookie not set in browser.";
> exit;
> }
> $sidarray = explode("+", "$vios");
> $user= $sidarray[0];
> $server= $sidarray[1];
> $port= $sidarray[2];
> $channel= $sidarray[3];
> $email= $sidarray[4];
> $fullname=$sidarray[5];
> $sk= $sidarray[6];
> $voice= $sidarray[7];
> $usevoice= $sidarray[8];
> $password= $sidarray[9];
> ?>


Hi R. Vince,

Cookies are set PER DOMAIN and possible even with a PATH in that domain.
That means that a cookie set at:
http://www.example.com cannot be retrieved by:
http://www.yetanotherdomain.com

By not retrieving I mean:
1) Is NEVER send to the server
2) Cannot be queried by Javascript.

So in effect a cookie from another domain is effectively not there.
This has been like this since... Netscape2 if memory serves me well.

Regards,
Erwin Moller
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:30 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0