Netscape cookie problem with 2nd, secure server
| From: | Rod Goodwin | Date: | Fri, 08 Sep 2000 20:00:08 +0000 |
| Subject: | Netscape cookie problem with 2nd, secure server | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15938@lists.php.net to get a copy of this message | ||
Hi, I've been having trouble getting a cookie to load on a secondary server
through Netscape.
It functions o.k. on IE.
The cookie passes it's value via a hidden form from myserver1 to the
_secure_ myserver2 and the cookie is supposed to regenerate on the other
server with the same name, data, expire, but its domain. I thought it might
be the path or header or the secure flag but nothing works with Netscape.
The other server's url is in the form
http://www.mydomain2.com/www.mydomain1.com
I put domain1.com in the header,
because I want to go back to the original site after logoff. I don't think
it matters that it is attempting to create 2 cookies with the same
name/info -different domain.
Thanks for your time---
pass the value $cart_id to this page
<?
if(!isset($cartID)) {
// recovers cart id number from non-secure site
SetCookie("cartID",$cart_id,time()+3600,"/",".mydomain2.com");
// even attempted to set
$cartID = $cart_id;
}
?>
<?
if(!isset($store_user_cookie) && !isset($store_user) || ($store_user_cookie
== 'deleted')) {
?>
<table border=1 width=500 cellspacing=0 cellpading=8>
<tr>
<td align=center colspan=2>
You must login before buying items.
</td>
</tr>
<tr>
<td align=center>
<form method=post action="<? echo $PHP_SELF; ?>">
<table>
<tr>
<td>
<b>Username:</b>
</td>
<td>
<input type=text size=20 name="store_user">
</td>
</tr>
<tr>
<td>
<b>Password:</b>
</td>
<td>
<input type=password size=20 name="store_user_pw">
</td>
</tr>
<tr>
<td colspan=2>
<input type=submit name="login" value="Login">
</td>
</tr>
<tr>
<td colspan=2>
To create an account (it's free) <a href="agreement.php3">click
here</a>.
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
die();
}
elseif($login == "Login" && !isset($store_user_cookie)) {
$username=strtolower($store_user);
$password=$store_user_pw;
$query = mysql_query("select username,password from $table where
username='$username' and password='$password'");
if(!mysql_num_rows($query))
?>
<body>
<table border=1 width=500 cellspacing=0 cellpading=8>
<tr>
<td>
<table>
<tr><td>Invalid username/password combination.<br>
You must login before buying items. To create an account (it's free)
<a href="agreement.php3">click here</a>.
</td></tr>
</table>
</td></tr>
</table>
<?
die();
}
SetCookie("store_user_cookie",$username,time()+3600,"/",".mydomain2.com");
}
elseif($action == "logoff") {
SetCookie("store_user_cookie","",time()+3600,"/",".mydomain2.com");
Header("Location: http://www.mydomain1.com");
}
elseif(isset($store_user_cookie)) {
echo "<table bgcolor=\"#FF0000\" cellpadding=0 cellspacing=0 border=0
width=30%><tbody><tr>
<td align=left>
<i>$store_user_cookie</i> is logged in.
<a
href=\"this-page.php3?action=logoff\">logoff</a></td></tr></tbody>
</td></tr></tbody></table>";
}
?>