As you may have noticed on this site, a color scheme can be selected on the left and it will be remembered as you navigate the site. It will even be remembered for a months time, or however long I would decide to have it set.
Simply put, setting a cookie is the perfect way to make your site truly dynamic to every visitor.
Here is the code used on the site you are visiting today:
setcookie(“color”,”red”, time()+3600 *24*14, “/”, “.blazekwebdesign.com”);
Let me break this down for you. “color” is the cookies name and “red” is the value of the cookie. “time()+3600*24*14″ This sets the DATE/TIME of the cookies expiration. The 3600 represents the seconds in an hour x 24 means the cookie will expire in 24 hours. If I multiply that by another number that represents how many days away it will expire. In this case it is 14 days until expiration.
Next is the “/”, this is the path that the cookie is available to. Setting it to “/” ensures your cookie is available to all pages and directories on your site. Setting it to “/blog/” will make this cookie available to only those of the pages within that directory.
Finally is the “.blazekwebdesign.com” which is the domain that the cookie is set for. Adding the period in front of the domain like this ensures maximum browser compatibility.
Now how do you access this cookie?
$colorfound = $_COOKIE["color"];







