Title: Cookie-based setting not applying
Last modified: February 10, 2022

---

# Cookie-based setting not applying

 *  Resolved [almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * (@almirdzankovic)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/)
 * Hello!
 * I am making a setting in my WooCommerce website where the user can choose between
   a table view and a grid view of the products. I use cookies for this. The setting
   works fine when clicking on it; but when changing page, when there is pagination,
   it doesn’t always retain the selected view.
 * I set the cookie like this:
 * `document.cookie = "Techsaker_se_vyval=Rutnätsvy";`
 * And then, in my content-product.php file I check it like this:
 *     ```
       // If table view not set to grid, show table view
       if (($_COOKIE['Techsaker_se_vyval']) != 'Rutnätsvy') {
       ```
   
 * It seems the cookie value isn’t retained.
 * Additionally, it will sometimes also show the table view on one page of a product
   category, and then the grid view on a different page.
 * Does anyone know why this could be happening?
 * Thanks!
    -  This topic was modified 4 years, 3 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
    -  This topic was modified 4 years, 3 months ago by [James Huff](https://wordpress.org/support/users/macmanx/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcookie-based-setting-not-applying%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * (@almirdzankovic)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15353668)
 * I have now observed that if I print the cookie value to the console with console.
   log, the value is often different from when I print it from the php with:
 * `var_dump($_COOKIE['Techsaker_se_vyval']);`
 * Right now for example when testing this, they show conflicting values on page
   1 of my shop startpage and the same values on page/2/. And I can only change 
   the value succesfully on page 2.
 * Now after further tests, I have observed that the JavaScript and php sometimes
   do show the same value also on page 1, but even then, I can’t change the view
   on page 1. The JavaScript value in the console sometimes changes, sometimes not
   even that. However, in a product category I have seen that I could change the
   view on both page 1 and and page 2.
 * It’s always the php value that determines what view is output. Why isn’t it always
   registering the same value as the JavaScript?
 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15354375)
 * Hello,
 * Sorry to hear that. To understand better your site setup, please provide the 
   following:
 * * Could you please share a copy of your site’s **System Status**? You can find
   it via **WooCommerce > Status**. Select “Get system report” and then “Copy for
   support”.
 * * Error Log: Share a copy of any fatal **error log** found under **WooCommerce
   > System Status > Logs **(if available).
 *  Thread Starter [almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * (@almirdzankovic)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15354431)
 * Hi.
 * Yes, here comes the System Status:
 *     ```
       ### WordPress Environment ###
   
       WordPress address (URL): https://techsaker.se
       Site address (URL): https://techsaker.se
       WC Version: 5.9.0
       REST API Version: ✔ 5.9.0
       WC Blocks Version: ✔ 6.1.0
       Action Scheduler Version: ✔ 3.3.0
       WC Admin Version: ✔ 2.8.0
       Log Directory Writable: ✔
       WP Version: ❌ 5.8.3 – Det finns en nyare version av WordPress tillgänglig (5.9)
       WP Multisite: –
       WP Memory Limit: ❌ 51 MB - Vi rekommenderar att du använder minst 64MB i minne. Läs: Öka minnet som allokeras till PHP
       WP Debug Mode: –
       WP Cron: ✔
       Language: sv_SE
       External object cache: –
   
       ### Server Environment ###
   
       Server Info: Apache
       PHP Version: 7.4.27
       PHP Post Max Size: 256 MB
       PHP Time Limit: 300
       PHP Max Input Vars: 5000
       cURL Version: 7.68.0
       OpenSSL/1.1.1f
   
       SUHOSIN Installed: –
       MySQL Version: 5.5.5-10.3.32-MariaDB-1:10.3.32+maria~focal
       Max Upload Size: 256 MB
       Default Timezone is UTC: ✔
       fsockopen/cURL: ✔
       SoapClient: ✔
       DOMDocument: ✔
       GZip: ✔
       Multibyte String: ✔
       Remote Post: ✔
       Remote Get: ✔
   
       ### Database ###
   
       WC Database Version: 5.9.0
       WC Database Prefix: wp_
       Total databasstorlek: 5.75MB
       Datastorlek för databas: 4.37MB
       Indexstorlek för databas: 1.38MB
       wp_woocommerce_sessions: Data: 0.02MB + Index: 0.00MB + Motor MyISAM
       wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
       wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
       wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
       wp_woocommerce_order_items: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
       wp_woocommerce_order_itemmeta: Data: 0.01MB + Index: 0.02MB + Motor MyISAM
       wp_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
       wp_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
       wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_actionscheduler_actions: Data: 0.02MB + Index: 0.13MB + Motor InnoDB
       wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_berocket_termmeta: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_braapf_product_stock_status_parent: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_braapf_product_variation_attributes: Data: 0.02MB + Index: 0.05MB + Motor InnoDB
       wp_braapf_term_taxonomy_hierarchical: Data: 0.06MB + Index: 0.05MB + Motor InnoDB
       wp_braapf_variable_attributes: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_braapf_variation_attributes: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_commentmeta: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
       wp_comments: Data: 0.01MB + Index: 0.01MB + Motor MyISAM
       wp_links: Data: 0.00MB + Index: 0.00MB + Motor MyISAM
       wp_ninja_table_items: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_options: Data: 1.42MB + Index: 0.10MB + Motor MyISAM
       wp_postmeta: Data: 1.89MB + Index: 0.07MB + Motor MyISAM
       wp_posts: Data: 0.10MB + Index: 0.05MB + Motor MyISAM
       wp_serial_numbers: Data: 0.02MB + Index: 0.08MB + Motor InnoDB
       wp_serial_numbers_activations: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_termmeta: Data: 0.02MB + Index: 0.03MB + Motor MyISAM
       wp_terms: Data: 0.01MB + Index: 0.03MB + Motor MyISAM
       wp_term_relationships: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
       wp_term_taxonomy: Data: 0.01MB + Index: 0.02MB + Motor MyISAM
       wp_usermeta: Data: 0.01MB + Index: 0.01MB + Motor MyISAM
       wp_users: Data: 0.00MB + Index: 0.01MB + Motor MyISAM
       wp_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_wcpt_sessions: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Motor InnoDB
       wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Motor InnoDB
       wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Motor InnoDB
       wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Motor InnoDB
       wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Motor InnoDB
       wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Motor InnoDB
       wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Motor InnoDB
       wp_wpml_mails: Data: 0.11MB + Index: 0.00MB + Motor InnoDB
   
       ### Post Type Counts ###
   
       attachment: 88
       br_filters_group: 5
       br_labels: 1
       br_product_filter: 12
       br_product_tab: 1
       br_tabs_location: 2
       customize_changeset: 5
       nav_menu_item: 21
       ninja-table: 1
       page: 20
       post: 2
       product: 17
       revision: 140
       shop_order: 3
       sidebar: 8
       wafs: 4
       wc_product_table: 14
       wpt_product_table: 1
       yith_wcan_preset: 2
   
       ### Security ###
   
       Secure connection (HTTPS): ✔
       Hide errors from visitors: ✔
   
       ### Active Plugins (29) ###
   
       Accordion Toggle: av WPDeveloper – 1.0.6
       WooCommerce Advanced Product Labels: av BeRocket – 1.2.3.4
       Category Editor: av Kevin Heath – 3.8.3
       Easy Auto SKU Generator for WooCommerce: av Dan Zakirov – 1.0.8
       Font Awesome: av Font Awesome – 4.0.4
       Site Kit by Google: av Google – 1.46.0
       Loco Translate: av Tim Whitlock – 2.5.5
       one.com: av one.com – 2.0.21
       Shipmondo för WooCommerce: av Shipmondo – 4.0.9
       Password Protected: av Ben Huson – 2.5
       Products Compare for WooCommerce: av BeRocket – 3.5.7.2
       PublishPress Revisions: av PublishPress – 3.0.6
       Sequential Order Numbers for WooCommerce: av BeRocket – 3.5.7.2
       Show Current Template: av JOTAKI Taisuke – 0.4.6
       WooCommerce Product Table PRO: av WC Product Table – 2.4.1
       WooCommerce Serial Numbers: av pluginever – 1.2.8
       Multiple Shipping Solution for WooCommerce: av Berend de Jong – 1.2.0
       Woo Custom Stock Status: av Softound Solutions – 1.3.0
       WooCommerce Order Test: av WP Fix It – 1.6
       WPC Product Timer for WooCommerce: av WPClever – 3.5.7
       WooCommerce Advanced Free Shipping: av Jeroen Sormani – 1.1.4
       WooCommerce AJAX Products Filter: av BeRocket – 3.1.1.2
       WooCommerce Category Accordion Plus: av TechieResource – 1.0
       WooCommerce Extra Product Sorting Options: av SkyVerge – 2.9.0
       WooCommerce PDF Invoices & Packing Slips: av Ewout Fernhout – 2.11.0
       WooCommerce: av Automattic – 5.9.0 (en uppdatering till version 6.2.0 finns tillgänglig)
       WooSidebars: av WooCommerce – 1.4.5
       WP Mail Logging: av Wysija – 1.10.2
       Custom Product Tabs for WooCommerce: av YIKES
       Inc. – 1.7.7
   
       ### Inactive Plugins (13) ###
   
       Akismet Anti-Spam: av Automattic – 4.2.1
       Display Template Name: av Aurélien Chappard – 1.7.1
       Easy Custom Sidebars: av Titanium Themes – 2.0.1
       Estimated Delivery Date for Woocommerce (Basic): av PluginHive – 1.3.3
       Grid/List View for WooCommerce: av BeRocket – 1.1.3.2
       Hello Dolly: av Matt Mullenweg – 1.7.2
       Ninja Tables: av WPManageNinja LLC – 4.1.6
       Performance Cache: av one.com – 1.0.16
       Product Table for WooCommerce - (wooproducttable): av CodeAstrology – 3.0.8
       Responsive Menu: av ExpressTech – 4.1.4
       WC Hide Shipping Methods: av Rynaldo Stoltz – 1.5
       WPB Accordion Menu or Category: av wpbean – 1.4.2
       YITH WooCommerce Compare: av YITH – 2.7.0
   
       ### Settings ###
   
       API Enabled: ✔
       Force SSL: ✔
       Currency: SEK (kr)
       Currency Position: right
       Thousand Separator: .
       Decimal Separator: ,
       Number of Decimals: 2
       Taxonomies: Product Types: external (external)
       grouped (grouped)
       simple (simple)
       variable (variable)
   
       Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
       exclude-from-search (exclude-from-search)
       featured (featured)
       outofstock (outofstock)
       rated-1 (rated-1)
       rated-2 (rated-2)
       rated-3 (rated-3)
       rated-4 (rated-4)
       rated-5 (rated-5)
   
       Connected to WooCommerce.com: –
   
       ### WC Pages ###
   
       Butikbas: #4 - /
       Kundvagn: #5 - /kundvagn/
       Kassan: #6 - /kassa/
       Mitt konto: #7 - /mitt_konto/
       Allmänna villkor: #18 - /kopvillkor/
   
       ### Theme ###
   
       Name: Techsaker
       Version: 1.0.0
       Author URL: http://almirdzankovic.com
       Child Theme: ✔
       Parent Theme Name: Storefront
       Parent Theme Version: 3.9.1
       Parent Theme Author URL: https://woocommerce.com/
       WooCommerce Support: ✔
   
       ### Templates ###
   
       Overrides: techsaker/woocommerce/archive-product.php
       techsaker/woocommerce/content-product.php
       techsaker/woocommerce/loop/add-to-cart.php
       techsaker/woocommerce/loop/loop-end.php
       techsaker/woocommerce/loop/loop-start.php
       techsaker/woocommerce/loop/price.php
       techsaker/woocommerce/loop/sale-flash.php
   
       ### Action Scheduler ###
   
       Färdigbehandlad: 41
       Oldest: 2022-01-17 10:16:33 +0000
       Newest: 2022-02-11 03:17:28 +0000
   
       ### Status report information ###
   
       Generated at: 2022-02-11 11:20:21 +01:00
       ```
   
 * The only fatal errors from today I think are unrelated to this. Here they are:
 *     ```
       2022-02-11T08:44:44+00:00 CRITICAL syntax error, unexpected ':', expecting ')' i /customers/0/8/e/techsaker.se/httpd.www/wp-content/themes/techsaker/functions.php på rad 582
   
       2022-02-11T08:44:44+00:00 CRITICAL syntax error, unexpected ':', expecting ')' i /customers/0/8/e/techsaker.se/httpd.www/wp-content/themes/techsaker/functions.php på rad 582
       ```
   
 *  Thread Starter [almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * (@almirdzankovic)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15354657)
 * I have asked about this on Stack Overflow as well, I have added some more code
   there and you can see that here: [https://stackoverflow.com/questions/71078819/cookie-stored-setting-not-applying](https://stackoverflow.com/questions/71078819/cookie-stored-setting-not-applying)
 * Thank you!
 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15356385)
 * Hi [@almirdzankovic](https://wordpress.org/support/users/almirdzankovic/),
 * Although I don’t think this can be associated with the issue you’re mentioning,
   we recommend a WordPress memory limit of 256 MB or greater for running WooCommerce.
   Here you can consult our server recommendations: [https://woocommerce.com/document/server-requirements/](https://woocommerce.com/document/server-requirements/).
 * Custom coding falls outside the scope of our support policy – [https://woocommerce.com/support-policy/](https://woocommerce.com/support-policy/),
   but you can also visit the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
   We’re lucky to have a great community of open-source developers for WooCommerce,
   and many of our developers hang out there, as well.
 * Cheers.
 *  Thread Starter [almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * (@almirdzankovic)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15360066)
 * Hello!
 * Thank you for the information. I use this web hosting plan to make websites, 
   but i’ll take a look at the recommendations. And I didn’t know about the WooCommerce
   Community Slack, I might join that as I learn more about WordPress- and WooCommerce
   development.
 * Have a good day!
 *  [aetta](https://wordpress.org/support/users/chiape/)
 * (@chiape)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15360233)
 * Hi [@almirdzankovic](https://wordpress.org/support/users/almirdzankovic/)
 * Cool! I’m going to mark this as resolved, so feel free to create a new topic 
   if you have other questions!
 * All the best!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Cookie-based setting not applying’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [cookies](https://wordpress.org/support/topic-tag/cookies/)

 * 7 replies
 * 4 participants
 * Last reply from: [aetta](https://wordpress.org/support/users/chiape/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/cookie-based-setting-not-applying/#post-15360233)
 * Status: resolved