We want to create some logic using JS that creates a cookie and set the node's taxonomy term id (preferred) or taxonomy term name as the cookie value. Then we want to use the cookie value to filter a View so that when a user visits a page, the view that is shown is filter based on the cookie value.

How can I pass a cookie value into the View?

/******************** Update - 9/23/2015 **************************/

I ended up using a mixture of a list block, javascript, and a custom module that on full node view, the taxonomy term id is stored into the browser's locale storage. I am no longer using a filter view based on cookie. Also, the custom module stores the taxonomy term ids into the block.

  • 1
    so you want when a user visits page x to grab the tax term id of page x and put it cookies, so when the user goes to page y, the page y view gets filtered by the page x tax term id?
    – No Sssweat
    Commented Aug 16, 2015 at 6:56
  • @NoSssweat Yes, you are correct. We are having trouble figuring out what is the best way to get the taxonomy term into a cookie value via JS. We have heard it is possible, but we are finding it to be difficult. Once we have the cookie value, we want to pass that cookie value into a view which always displayed on page x and y. the View essentially would filter based on the cookie value. The most difficult part has been that we do not see a way to take in a cookie value from a View. Any thoughts or know of any tutorials we could use to help us? Commented Aug 17, 2015 at 21:31
  • 1
    You could embed the view using php ex: print views_embed_view('my_view_name', 'block_1', $termIDcookie); You would then need to figure out how to pass a cookie for $termIDcookie in PHP
    – No Sssweat
    Commented Aug 17, 2015 at 23:50

1 Answer 1


On May 26th 2011 a new EU originated law came into effect that requires website owners to make significant changes to their sites and may fundamentally change the whole web browsing and shopping experience for everybody.This Cookie Law is amended privacy legislation that requires websites to obtain informed consent from visitors before they can store or retrieve any information on a computer or any other web connected device.

Cookie Control does just that, presenting users with clear information on whether cookies are present, linking to your privacy policy (where you should have specific information about what cookies are in use), and advising users on how to adjust browser settings and what cookies mean for them.


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.