Re: Multiple cookies, one site
StinkFinger wrote:[color=blue]
> I am using two separate setcookies to create and maintain cookies for every
> day users and one for admins.
>
> When a casual user hits a page I use this:
> setcookie($bm[$i]['bm_pid'],$bm[$i]['bm_title'],time()+3153600 0,"/",".mydoma
> in.com");[/color]
Put user's cookies in a separate array in the $_COOKIE variable
setcookie('user['.$bm[$i]['bm_pid'].']', $bm[$i]['bm_title'], ...);
[color=blue]
> and an admin logs in it uses this:
> setcookie("admi n","$admin",tim e()+7200);[/color]
Put admin's cookies in their own array entry
setcookie('admi n[admin]', $admin, time()+7200);
[color=blue]
> The above created 2 different cookies, one for Cookie:user@myd omain.com/ and
> one for Cookie:user@www .mydomain.com/
>
> This way, later on I can call this to retrieve and show them what the have
> "recently viewed":
>
> foreach ($_COOKIE as $cookievalue) {[/color]
foreach ($_COOKIE['user'] as $cookievalue) {
[color=blue]
> echo $cookievalue;
> echo "<br>";
> }[/color]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Multiple cookies, one site
Collapse
This topic is closed.
X
X
-
Guest replied -
Multiple cookies, one site
Hello all,
I am using two separate setcookies to create and maintain cookies for every
day users and one for admins.
When a casual user hits a page I use this:
setcookie($bm[$i]['bm_pid'],$bm[$i]['bm_title'],time()+3153600 0,"/",".mydoma
in.com");
and an admin logs in it uses this:
setcookie("admi n","$admin",tim e()+7200);
The above created 2 different cookies, one for Cookie:user@myd omain.com/ and
one for Cookie:user@www .mydomain.com/
This way, later on I can call this to retrieve and show them what the have
"recently viewed":
foreach ($_COOKIE as $cookievalue) {
echo $cookievalue;
echo "<br>";
}
The problem is, it also reads in the stuff in the admin cookie. How can I
make it so that ONLY the casual users cookie information is read in ? I was
trying to avoid using sessions, and writing stuff to my db, etc.
I just wanted a quick and dirty way to have it remember certain pages that
were visited and show them (similar to amazon.com).
Many thanks.
Tags: None
Leave a comment: