Can anyone tell me why...
when a user logs into my site, a cookie is created that holds some info. The user is then taken to the default index page (index.php).
Some menu options on this page call the index.php page again, and pass variables via the URL query string. (index.php?action=sports)
Now index.php is still used to generate the menus, but action=sports causes a page to be included (<?php include ('http://www.domain.com/sports.php?cat=0'); ?>
Because the include has a query string on the URL, the http part is required, without it php tries to find a page named 'sports.php?cat=0' and not a page named 'sports.php' with a quiry string of 'cat=0.'
Okay, now the problem. Using the fully qualified URL (with the http part) the included page can not see the cookie. It treats the user as if they are not logged in... the index.php page still knows they are there, but the included page asks them to login.
- it is all under the same domain name.
- both pages are set to use the same cookie.
Can anyone suggest a work around? A different way to include the file? Anything else?
Thanks!
cookie variables and included files
Moderator: General Moderators
-
seveninstl
- Forum Newbie
- Posts: 4
- Joined: Fri May 14, 2004 12:38 pm
- Location: Kissimmee, FL
- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
Why not just do it like this:
sports.php will have access to ANY variables that have been set up until that point in your script, hence it will be able to recognise $cat.
Code: Select all
$cat = 0;
include 'sports.php';