wp-graphql-woocommerce
wp-graphql-woocommerce copied to clipboard
Send (and check for) woocommerce-session as a cookie instead of header.
Is your feature request related to a problem? Please describe.
Many frontend graphql clients require modifying the fetch function to get access to response headers and then we have to write functions to store and retrieve the cart session from something like localStorage. In SvelteKit, I'm currently having to make an API endpoint solely for checking for the woocommerce-session
header, set is as a set-cookie
for the response to the client, and then look for the cookie on requests from the client and set it back as a regular header. If it's sent from the headless wordpress as an httpOnly cookie, many client configurations would be much simpler.
Describe the solution you'd like I'd like the cart session token to be sent as an httplOnly cookie. The plugin would then need to check for the presence of the cookie on incoming requests.
Describe alternatives you've considered
Either storing the woocommerce-session
header value in localStorage and setting it on each outgoing request, or making an API endpoint to implement the cookie functionality to reduce client-side code.
@revnelson Why not just use the set define( 'NO_QL_SESSION_HANDLER', true);
. This would make WooGraphQL default to traditional WooCommerce session handler which uses a HTTP cookie.
@revnelson Why not just use the set
define( 'NO_QL_SESSION_HEADER', true);
. This would make WooGraphQL default to traditional WooCommerce session handler which uses a HTTP cookie.
Just a small fix:
Correct: NO_QL_SESSION_HANDLER Not: NO_QL_SESSION_HEADER
☝🏿 Yea, what he said. Good catch on that @victormattosvm