[solved] $_COOKIE['variable'] Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
siefkencp
Forum Commoner
Posts: 69
Joined: Thu Dec 16, 2004 8:50 am

[solved] $_COOKIE['variable'] Problem

Post 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
Last edited by siefkencp on Thu Dec 16, 2004 1:17 pm, edited 1 time in total.
siefkencp
Forum Commoner
Posts: 69
Joined: Thu Dec 16, 2004 8:50 am

Post 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
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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);
siefkencp
Forum Commoner
Posts: 69
Joined: Thu Dec 16, 2004 8:50 am

Post by siefkencp »

Solved... I was setting the cookie with out giving path information for it.
Post Reply