1

I need to search for fields that are equal to the value of a visitor cookie. How do I get $_COOKIE[somecookie] as the criterion value in the views filter? (I know that I could use views_php to grab all the records and filter out after the fact but that's a lot of records and would be far too slow.)

It would be preferable to be able to do this without writing a custom module. It seems like this would be a common request by admins so I feel I'm missing something obvious.

1 Answer 1

2

Setup the page to use a contextual filter per field you want to be searchable. Then for the contextual filter set it to look for the value provided by the URL. Then select PHP Code for WHEN THE FILTER VALUE IS NOT IN THE URL.

In that PHP blob supply code that pulls the field argument from $_COOKIE, if any or return NULL.

1
  • 1
    Once I get the rep points I'll come back and upvote as well. Sep 13, 2013 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.