Create cookie if link clicked, redirects to clicked link on next visit
Asked Answered
R

2

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.

Ricard answered 9/11, 2012 at 17:54 Comment(1)
Javascript is well and good, but this kind of work is better suited for server-side handling.Psychologism
I
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

Interviewer answered 9/11, 2012 at 18:28 Comment(0)
F
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.

Floriated answered 10/11, 2012 at 2:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.