1. Home
  2. Computing & Technology
  3. PHP / MySQL

PHP CSS Switcher

By Angela Bradley, About.com

2 of 3

Setting The Cookie

Now we need a file that will simply set a cookie to the user's preferred style.
<?php
$Year =31536000 + time();
setcookie ('style', $choice, $year);
header("Location: $HTTP_REFERER");
?>
You can save this code as anything you want, in our example we'll assume you called it changestyle.php. Now to actually change the style all you need to do is pass the $choice variable along to this script. It will then place a style cookie that lasts one year into their browser, and then redirect them back to the referring page.
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. CSS Switcher PHP - PHP Style Switcher - PHP Change CSS

©2009 About.com, a part of The New York Times Company.

All rights reserved.