7

Site has two sections; 'Everywhere' and 'LA'.
Default is 'Everywhere' section.

How would I go about creating a cookie if the visitor clicks the 'LA' section link and when they return to the main site on another visit, they are redirected to that 'LA' section?

I've tried altering this script; http://www.javascriptsource.com/cookies/cookie-redirect.html

Instead of checkboxes, its a link and only one. But doesn't seem to work.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Tad Ward
  • 279
  • 2
  • 8
  • Javascript is well and good, but this kind of work is better suited for server-side handling. – TheZ Nov 09 '12 at 17:57

2 Answers2

4

What I do usually is create a conditional, and create an embed with the cookie inside. I also tend to use this add-on: http://devot-ee.com/add-ons/cookies

2

Tad,

For setting the cookie you are going to want to use javascript, using a click handler on the LA section link. If you need some help with setting the cookie in javascript there is a good introductory article at http://www.quirksmode.org/js/cookies.html which isn't bang up to date but is still in full working order.

Once the cookie is set then you will switch to using one of the plugins for EE so that you can check for the existence of it in a template (probably in the an embeded or snippeted template) on page load. If you find the cookie then you can use the standard EE redirect syntax to send the visitor to the relevant section.

Adam Wiggall
  • 393
  • 2
  • 7