Page 1 of 1

[solved] $_COOKIE['variable'] Problem

Posted: Thu Dec 16, 2004 8:55 am
by siefkencp
Below is my code which works great when I call the file it is in directly but I want to use it as an include. Does php not allow this?

Code: Select all

<?php
if (isset($_COOKIE['power_campus_num'])){
$id = $_COOKIE['power_campus_num'];
$fname = $_COOKIE['first_name'];
$lname = $_COOKIE['last_name'];
$page = $PHP_SELF;

$date = time();
$dbdate = date("m/d/y G.i:s", $date);

include '/var/www/html/phplib/mysql_connect.php';

mysql_query ("INSERT INTO admissions_stats (people_code_id , first_name , last_name , file , date) 
VALUES ('$id' , '$fname' , '$lname' , '$page' , '$dbdate')");

include '/var/www/html/phplib/close.php';

print "<!--Hit Logged-->";
}
?>
Chris Siefken

Posted: Thu Dec 16, 2004 10:30 am
by siefkencp
More info:

Include is not the problem.

Works great on the Mac.

Doesen't work on PC's

Checking the cookie on the mac reveals that the cookie name is http://www.sapc.edu with 3 different cookies for each value.

Checking on the pc reveals that it is the name of the folder /phplib/ and then all 3 values are in one cookie. The cookie on pc's can befound only when called in the folder /phplib/ which is where the cookie is created.

Im stumpped and Im now going to hunt through php.ini ...

Any thoughts help or otherwise would be greatly aprecieated.


Chris

Posted: Thu Dec 16, 2004 11:55 am
by rehfeld
put this at the VERY top of your script and see if you get any errors. put it in the file that gets parsed first, the file does that does the including of other files.

if you have a different page that sets the cookie in the first place, put it in there too.

error_reporting(E_ALL);

Posted: Thu Dec 16, 2004 1:17 pm
by siefkencp
Solved... I was setting the cookie with out giving path information for it.