Sorry if that's not an adequate description— I've only ever done some very basic delving into sessions, and never in drupal, and never involving javascript.

Here's what I'm trying to do:

I have a very simple piece of jQuery, which is basically as simple as this like:

jQuery(document).ready(function($) {
    $('#thisLink').click(function($) {
             $('#thatDiv').addClass('newClass');
    }
});

I need the addClass to persist after the user refreshes or changes pages.

Here's why: I have a View with a schedule and a "sticky" map. I want to give users the option to "unstick" the map. The View has non-ajax exposed filters, so the map "unstick" would become sticky again every time the user uses a filter and the page refreshes.
Also, it can't be bound to a login, because I have persistent logins set up, so the user may not have actually logged in for that session. I'm okay if the 'clicked' state persists for only that time that user is browsing, or if it persists for the entire time they're logged in (which is indefinitely).

Also, if there is a better way than tying this to sessions, let me know. I'm shooting blindly on this one.

ETA: Or am I going about this completely wrong, and need to use cookies?

Comments

mitchmac’s picture

Is your jQuery snippet generated with php? If not, I would stick to using a cookie and javascript to take care of this, using session data and PHP just adds more pieces to the puzzle, IMO.

KerriO’s picture

It is actually generated through my template.php file (and is already in an if statement), so adding php wouldn't further complicate things in this case (in terms of where all the pieces are located, at least…).