scriptygoddess

17 Jun, 2003

Reset Skin Preference Cookie

Posted by: Jennifer In: Script snippet

Originally posted at http://blog.kevindonahue.com

I presented Jennifer with a question: How do I remove skins? or –to be more specific– How do I let users delete their skin preferences and use the current default?

I skin my site based on the examples provided by Brenna and Amy. There is always good info at Girlie's site and lots of others.

In order to delete the cookie, the user has to request the page that deletes the cookie. On my site, that page is http://blog.kevindonahue.com/skins/reset.php. So a link that looks like this:

<a href="http://www.yourdomain.com/reset.php">reset skins</a>

connects to a page that deletes the cookie called "skin" using this php:

&lt?php
setcookie('skin',",time(),'/');
setcookie('skin',",time(),'/','.yourdomain.com');
header('location: http://www.yourdomain.com');
?>

Notes: The first two lines set the cookie to nothing (that's not a double quote in there, it's two single quotes with nothing in between them) – and the last line redirects them to your whatever page you want to put there. You don't need anything else on that page except that code. The name of the cookie ('skin') must be the same name as the cookie you are setting when the user selects their skin preference. For me, that takes place on a page called "testskin.php".

Again, this is the solution that works for me. Your milage may vary, depending on how you have implemented skins on your site. I would really like for other sites to consider implementing this concept, as it would save me the trouble of deleting their cookies periodically to see what skin they're currently featuring. I'm not much help for configuring it to work for you.

1 Response to "Reset Skin Preference Cookie"

1 | lynda

June 18th, 2003 at 10:04 am

Avatar

Thanks for the tip – always good to get this out there.

When deleting cookies, it's preferable to set the time to something in the past. time()-3600 is standard. Otherwise, you're just setting a blank cookie.

reference php.net on cookies

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements