Title: Initialize Session in Rest API requests
Last modified: March 21, 2025

---

# Initialize Session in Rest API requests

 *  Resolved [Memo](https://wordpress.org/support/users/gtenaschuk/)
 * (@gtenaschuk)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/initialize-session-in-rest-api-requests/)
 * Hi Team,
 * We are working on a custom plugin that will allow you to select tickets from 
   a seat map and purchase them.
 * The plugin will connect to a external API that will validate if the seat is available
   and mark the seat as reserved, we are doing this validation and reservation using
   a Rest API endpoint created in our plugin. As we would like to have the reservation
   associated with the WooCommerce customer ID we were trying to use the WooCommerce
   Customer stored in the session but the WC()->session is null on every request
   and if we try to initialize the session by ourselves, in the woocommerce_init
   action, and store it in the cookies it is not working properly, it is generating
   a new random customer ID on every request and trying to store the new id in the
   cookies.
 * Also we tried to call the store cookies method on the wp_load action to see if
   it stored the customer id in the cookies and use it later in the rest-api call
   but no luck.
 * Can you please tell us if there is a way to do this? or recommend an option about
   how we could initialize the session earlier to have the customer id consistent
   during the session.
 * Thanks!

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

 *  [Mahfuzur Rahman](https://wordpress.org/support/users/mahfuzurwp/)
 * (@mahfuzurwp)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/initialize-session-in-rest-api-requests/#post-18373747)
 * Hi [@gtenaschuk](https://wordpress.org/support/users/gtenaschuk/) ,
 * Thank you for reaching out! While we understand your custom plugin development
   needs, please note that assistance with custom code is outside of our support
   scope. However, we highly recommend joining our [community Slack](https://woocommerce.com/community-slack/)
   channel, where you can collaborate with other developers and get insights or 
   suggestions on your custom development challenges.
 * Feel free to check out the community and get in touch with others who might have
   faced similar issues.
 * Best of luck with your project!
 *  Thread Starter [Memo](https://wordpress.org/support/users/gtenaschuk/)
 * (@gtenaschuk)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/initialize-session-in-rest-api-requests/#post-18375477)
 * [@mahfuzurwp](https://wordpress.org/support/users/mahfuzurwp/)
 * The problem we have is that when using WC()->session in a REST API endpoint call
   it is always null and not sure why.
 * I will send this question to the slack channel as well to see if someone has 
   the same problem.
 *  Thanks!
 *  [Zee](https://wordpress.org/support/users/doublezed2/)
 * (@doublezed2)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/initialize-session-in-rest-api-requests/#post-18376341)
 * Hello [Memo](https://wordpress.org/support/users/gtenaschuk/)
 * Thank you for your reply.
 * I understand you are posting this question on Slack. It is the right channel 
   to seek answers related to custom development. This forum is intended for support
   related to WooCommerce core features and configurations.
 * Have a great day!

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

The topic ‘Initialize Session in Rest API requests’ 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

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

 * 3 replies
 * 3 participants
 * Last reply from: [Zee](https://wordpress.org/support/users/doublezed2/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/initialize-session-in-rest-api-requests/#post-18376341)
 * Status: resolved