Page 1 of 2
calling all cookie problems that is
Posted: Sun Jul 07, 2002 7:10 pm
by cheatboy00
i'm tring to call up a cookie and dectect whats in it and if its users or watever then do this... but even tho i know the cookies are there its not calling up the right page... see in the header.php file i have this
Code: Select all
if ($page == 'login' && $ucp == 'user' OR isset ($logcbaa) == 'user'){
include ("ucp.php");
}
to call the right control panel, for the type of user, and if they just come to the site and loggedin previously and never logged out then it should still have the cookies and log them in automaticly..... see the first part of the if statement is correct that works is the or.... that doesnt... does anyone know whats wrong
Posted: Mon Jul 08, 2002 2:08 am
by twigletmac
Assuming $logcbaa is the cookie have you tried, $_COOKIE['logcbaa']?
Mac
Posted: Mon Jul 08, 2002 10:05 pm
by cheatboy00
nope that didnt work
see i know the cookies are on my computer buts its like its not finding them or somethign... am i doing somethign wrong when i set the cookies....
Code: Select all
setcookie ("idcbaa",$id,time()+604800);
setcookie ("logcbaa",$stat,time()+604800);
Posted: Mon Jul 08, 2002 10:08 pm
by cheatboy00
maybe the cookie isnt lasting as long and its surpose to is the time right?........... its surpose to be a week
Posted: Mon Jul 08, 2002 10:13 pm
by Elfstone
If you are using an include statement to include the file that has the code which checks the cookies, be sure to include using the path on the server as opposed to the URL.
Posted: Tue Jul 09, 2002 8:35 pm
by cheatboy00
what?????
the code that checks teh cookies is on header.php which is included from the index2a.php file (the main one)
and i have no idea how to .... include using the path on the server as opposed to the URL. ???
Posted: Wed Jul 10, 2002 12:45 am
by cheatboy00
well there is no error that shows up so i dont know exactly....
everythign works except for teh fact that my cookies are not functioning i set the cookie but i duno why its not being called up when i call it
the whole objective is to get it so that when you login.... it sets a cookie called cblog and it has your status for what user panel you get so if your status is just a user your only allowed certian things etc...
that works logging in works... but when you come back to the site or go to somewhere else on the site it doesnt show the control panel anymore.... it'll just show the login screen...
thats my whole problem...... erg... see what i do i use an if to check to see if the cookies set and get the cookie what is teh value of the cookie and if it matches one of the properties i ahve lined out (user... staff.... admin), then go to the one it matches but it doesnt....
Posted: Wed Jul 10, 2002 1:55 am
by cheatboy00
i found the whole problem...
its not getting the cookies....
when i make it so that the cookie has to be there to show a control panel, nothign shows up. making the control panel show up is all up to the cookie
for some reason its not finding or getting the cookie...
well the cookies might not even be on my hard drive becasue i've tried searching for them but havent found them i set the dir on the cookie to "/" where would that be ... in the c:/ drive.. i duno
Posted: Wed Jul 10, 2002 2:06 am
by twigletmac
To check what cookies your site has set do:
Code: Select all
echo '<pre>';
print_r($_COOKIE);
echo '</pre>';
Cookies are generally stored with your temporary internet files so check that folder.
Mac
Posted: Wed Jul 10, 2002 5:57 pm
by cheatboy00
.. this is what comes up when i do that
Array
(
[idcbaa] => 2
[logcbaa] => user
)
so does that mean inside the first cookie it has the value [idcbaa] => 2 like all together like that or it the [idcbaa] just the name and the value is whats after the => thing well if it is that means its setting the cookie right but its not picking it up in the if statement
Posted: Wed Jul 10, 2002 6:01 pm
by cheatboy00
i found my cookies their in the temporary internet file folder.. under a text file called cbaa..... it contains both cookies... so should i isset($cbaa) .. becasue they are both in that file?....
Posted: Wed Jul 10, 2002 8:04 pm
by Elfstone
Clarification about my include comment.....if using the include function, be sure you are using a path(Something like /usrs/me/web/file.php) as opposed to a URL(
http://www.site.com/file.php). I've found that if you do the latter, it will not work with cookies very well, for some reason.
Secondly, This code you posted in your first post could be the problem.
Code: Select all
if ($page == 'login' && $ucp == 'user' OR isset ($logcbaa) == 'user'){
include ("ucp.php");
}
isset won't return 'user', only true or false. Could be your problem there.
Posted: Wed Jul 10, 2002 9:02 pm
by cheatboy00
o.k. i got this code off of the php manual ... duno it still doesnt work... i changed the $logcbaa to $cbaa because i found that both of the cookies i set are in one file called cbaa.... this is makeing my head hurt
Code: Select all
if (isset($cbaa) && ($cbaa == "user")){
include ("ucp.php");
}
Posted: Wed Jul 10, 2002 9:19 pm
by Elfstone
One thing I just thought of, is..cookies can only be used either by files in the directory they were created in, or subdirectories from that directory. Make sure that's not the problem you are having.
If that isn't your problem, try making a blank page with only a simple code to echo out your cookie variable. That's the easiest way to tell wether it is setting them correctly or not.
Posted: Wed Jul 10, 2002 11:47 pm
by cheatboy00
you mean like the file with the set cookie is in ..../cbaa/filename.php
so make sure when i call the cookie the file thats calling it in has to be the same .....
well all my files for my web page are in /cbaa/ except for the pics which are in /cbaa/pics/