Yes you need to set the string domain http://us2.php.net/manual/en/function.setcookie.php that url should help you
From: "Jason T. Davidson" <davidson@xxxxxxxxxxxx>
Reply-To: davidson@xxxxxxxxxxxx
To: php-db@xxxxxxxxxxxxx
Subject: Cookies with databases
Date: Wed, 20 Oct 2004 19:54:54 -0500
MIME-Version: 1.0
Received: from pb1.pair.com ([216.92.131.4]) by mc8-f21.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Wed, 20 Oct 2004 18:10:29 -0700
Received: (qmail 42118 invoked by uid 1010); 21 Oct 2004 01:10:20 -0000
Received: (qmail 95202 invoked by uid 1010); 21 Oct 2004 00:55:20 -0000
X-Message-Info: JGTYoYF78jECeNGc3phkjLz5nkZbete3
Mailing-List: contact php-db-help@xxxxxxxxxxxxx; run by ezmlm
Precedence: bulk
list-help: <mailto:php-db-help@xxxxxxxxxxxxx>
list-unsubscribe: <mailto:php-db-unsubscribe@xxxxxxxxxxxxx>
list-post: <mailto:php-db@xxxxxxxxxxxxx>
Delivered-To: mailing list php-db@xxxxxxxxxxxxx
Delivered-To: ezmlm-scan-php-db@xxxxxxxxxxxxx
Delivered-To: ezmlm-php-db@xxxxxxxxxxxxx
Message-ID: <20041021005520.95145.qmail@xxxxxxxxxxxx>
Organization: UND Aerospace Foundation
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
X-Accept-Language: en-us, en
X-Posted-By: 24.197.179.243
Return-Path: php-db-return-36948-dbnm=hotmail.com@xxxxxxxxxxxxx
X-OriginalArrivalTime: 21 Oct 2004 01:10:29.0559 (UTC) FILETIME=[C167FC70:01C4B70A]
I am trying to set a cookie with a value from a database. Here is my script:
<? //Setting Cookies setcookie ('CIDcookie', "$cid"); setcookie ('USERcookie', "$user"); ?>
<? //Database connection require ("../../db_connect.php");
//Table Name $main_tbl = "MAIN" ?>
<? //Check the Password against the CID $query="SELECT * FROM $main_tbl WHERE CID='$cid'"; $result=mysql_query($query) or die(mysql_error()); $check=mysql_fetch_array($result);
if ($Message == "NoAccess"){
echo("<B><CENTER><FONT COLOR=RED>You do not have access to that page!</FONT></CENTER></B>\n");
include ("staff_code/admin_links.php");
}
if ($check[PASSWORD] != $_REQUEST[password]){
header("Location:staff_login.php?Message=Invalid");
}
if (($check[PASSWORD] == $_REQUEST[password]) AND ($check[USER] == "A")) {
include ("staff_code/admin_links.php");
$user = $check[USER];
}
else{
include ("staff_code/controller_links.php");
}
?>
Then on the second page it is reading the cookies, but it will display the CIDcookie, but not the USERcookie. Here is the script on the second page:
<? //Retrieve Cookies $cid = $_COOKIE['CIDcookie']; $user = $_COOKIE['USERcookie']; ?>
<html> <head> <title>ZMP ARTCC: Staff To Do List</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>
<? echo ("My CID is $cid"); echo ("$user"); ?>
<body text="#000066" link="#000066" vlink="#000066" alink="#000066">
<table width="600">
<tr>
<td><div align="center"><font size="4"><strong>ZMPs Staff TO Do List</strong></font></div></td>
</tr>
</table>
<br>
<table width="600">
<tr>
<td colspan="3" bgcolor="#999999"><div align="center"><strong><font size="3">Completed Tasks</font></strong></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="100"><div align="center">Date Finished</div></td>
<td width="250"><div align="center">Task</div></td>
<td width="250"><div align="center">Status</div></td>
</tr>
<tr>
<td><div align="center">10-13-04</div></td>
<td><div align="center">DLH SOP (new)</div></td>
<td><div align="center">Awaiting finish of other projects</div></td>
</tr>
<tr>
<td><div align="center">10-18-04</div></td>
<td><div align="center">ZMP Policies</div></td>
<td><div align="center">"</div></td>
</tr>
</table>
<br>
<table width="600">
<tr>
<td colspan="3" bgcolor="#999999"><div align="center"><strong><font size="3">
Tasks Awaiting VATUSA Approval</font></strong></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="100"><div align="center">Date Sent</div></td>
<td width="250"><div align="center">Task</div></td>
<td width="250"><div align="center">Status</div></td>
</tr>
<tr>
<td><div align="center">10-09-04</div></td>
<td><div align="center">LNK SOP (new)</div></td>
<td><div align="center">Awaiting approval</div></td>
</tr>
<tr>
<td><div align="center">10-19-04</div></td>
<td><div align="center">M98 SOP</div></td>
<td><div align="center">Awaiting Approval</div></td>
</tr>
<tr>
<td><div align="center">10-19-04</div></td>
<td><div align="center">General SOP</div></td>
<td><div align="center">Awaiting Approval</div></td>
</tr>
</table>
</body> </html>
So I am assuming that somewhere in my first page that my cookie isn't actually gettting set properly. I have tried many varitites and can't find any help sections on cookies from a database. Any help would be appreciated!
-- Jason Davidson
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
Check out Election 2004 for up-to-date election news, plus voter tools and more! http://special.msn.com/msn/election2004.armx
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php