I can create cookies but not call them - why??
Posted: Fri Dec 30, 2005 3:03 am
Ok, here is my dilema. It is driving me absolutely batty. I am creating my own cms with PHP / MySQL and I am getting the hang of it. I am using cookies to pass variables. I can set the cookies, and verify it in my browser that they are set just fine.
Firstly, my cms is setup with a config file which is always included first with index.php & then the theme file is included, which includes the HTML. So since I need to set the cookies before the HTML, I put the default cookies set in the config file. They use if statements:
I also have a form that passes post data and is transferred over to the cookies. I verify that this changes the cookie properly.
However, when I set any given page to call the cookie information, it won't work and I am going crazy.
Here is an example call:
This is an example variable I set for a mysql query. The query works perfectly if I replace the cookie calls with a static string.
What gives?
Thanks in advance!!

Firstly, my cms is setup with a config file which is always included first with index.php & then the theme file is included, which includes the HTML. So since I need to set the cookies before the HTML, I put the default cookies set in the config file. They use if statements:
Code: Select all
// COOKIE HEADERS
session_start();
if ( $_COOKIE['trans'] == null ) setcookie("trans", "LITV", 0, "/");
if ( $_COOKIE['book'] == null ) setcookie("book", "Genesis", 0, "/");
if ( $_COOKIE['chapter'] == null ) setcookie("chapter", "1", 0, "/");However, when I set any given page to call the cookie information, it won't work and I am going crazy.
Here is an example call:
Code: Select all
$query = "SELECT $fields FROM " . $_COOKIE["trans"] . "$queryextra";What gives?
Thanks in advance!!