Click here to Skip to main content
15,885,910 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I hope someone can help me here.

I have set my page up with a dynamic background (using PHP)
but when I change page, the background disappears.

I need to know, how to create a cookie (IN PHP) that will target the background and keep the background active as you change page.

I have 3 different options (red, green and blue.)
so I will also need to be able to make the cookie change if the person changes their mind on which colour they want.


my website URL is here : http://www.uuilliam.net/zombies

it is just a quick thrown up template just now with some filler text.

I appreciate and anticipate your replies.
Posted

In PHP5 this can be done with the help of $_COOKIE superglobal.
 
Share this answer
 
I know about $_COOKIE but I have only been learning coding for about... 20 - 30 weeks.
(learning mostly css and html, then just used some basic php now i need to go a little more advance.)

its the fact of, I do not know how to target the background.
I know that
setcookie(name, value, expire, path, domain);

goes at the top of the document (before )
but it is I don't know where the retrieving of the cookie goes.

I am guessing for me the cookie would be

setcookie (background, zombie, +108000);
?>

<title>


$_COOKIE['background']
// Print a cookie
echo $_COOKIE["background"];

// A way to view all cookies
print_r($_COOKIE);
?>


// set the expiration date to one hour ago
setcookie("background", "zombie", time()-3600);
?>

but then... that isn't targeting my background.

the background is shown in the url as ?hexcode

i.e.

http://www.uuilliam.net./zombies?d31111 or ?ffffff or ?0c0c0c etc...

I need the cookie to remember to add the hex code to the url after the person clicks a link to go onto the next page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900