Title: Updating a WC session with javascript
Last modified: July 11, 2022

---

# Updating a WC session with javascript

 *  Resolved [ancher](https://wordpress.org/support/users/ancher/)
 * (@ancher)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/)
 * Hi
    I am trying to find a way to update my WC session with JavaScript to avoid
   page reload. I have no problem setting regular sessions in PHP or JavaScript,
   but since its advised to use “WC()->session->set” instead of $_SESSION it gives
   me trouble updating it with JS. I basically need this line converted into JS.
 * `WC()->session->set('sess_test', 'new value');`

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

 *  [con](https://wordpress.org/support/users/conschneider/)
 * (@conschneider)
 * Engineer
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15819008)
 * Hi there,
 * I could not find any good way to do this with Javascript only. This is the best
   resource I found for a possible workaround: [https://pippinsplugins.com/storing-session-data-in-wordpress-without-_session/](https://pippinsplugins.com/storing-session-data-in-wordpress-without-_session/)
 * I am gonna leave this thread open to see if anybody can pitch in with better 
   input.
 * 🤞.
 * Kind regards,
 *  Thread Starter [ancher](https://wordpress.org/support/users/ancher/)
 * (@ancher)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15819725)
 * Thanks im gonna try this and return 🙂
 *  Plugin Support [Sol J. a11n](https://wordpress.org/support/users/solstudioim/)
 * (@solstudioim)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15820532)
 * Hi [@ancher](https://wordpress.org/support/users/ancher/)
 * > Thanks im gonna try this and return 🙂
 * Sounds like a great plan!
 * Do let us know how it goes!
 *  Thread Starter [ancher](https://wordpress.org/support/users/ancher/)
 * (@ancher)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15822177)
 * I have the same issues as if i used $_SESSION. I am gonna do it all PHP, until
   i find a way to update the value of a WC session in JS.
 *  Plugin Support [Kaushik S. a11n](https://wordpress.org/support/users/kaushiksomaiya/)
 * (@kaushiksomaiya)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15823512)
 * Hi there [@ancher](https://wordpress.org/support/users/ancher/)!
 * You could add the logic for updating the session in a PHP file.
 * Then, you could use JavaScript Ajax to call that file and update the session 
   by passing values via Ajax call. This won’t need a page refresh.
 * I hope this helps! 🙂

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

The topic ‘Updating a WC session with javascript’ 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/)

 * 5 replies
 * 4 participants
 * Last reply from: [Kaushik S. a11n](https://wordpress.org/support/users/kaushiksomaiya/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/updating-a-wc-session-with-javascript/#post-15823512)
 * Status: resolved