skip to Main Content

I am facing some issues while sharing the cookie between wordpress and reactjs application.

The following are the example IPs for frontend and wordpress:

If I login from the reactjs application or wordpress and vice-versa then wordpress logged in cookie will be shared with reactjs application which we are not getting.

I am using the GRAPHQL and GRAPHQL cors masters plugin at wordpress end. I am integrating the wordpress login at reactjs application.

The following is the CORS plugin for reference:
https://github.com/funkhaus/wp-graphql-cors

But, Cookie is shared at my local server perfectly but not at live server.
For local using the following:

  • Reactjs – http://localhost:3000
  • WordPress: http://localhost

I have added the SSL on both the IPs.
And I also find it there might be some CORS issue.

This is my CORS setting for GRAPHQL its for local but same i did for live only changed the IPs

enter image description here

I want to make cookie sharing or set cookie at live server too.

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for your response.. Now, I am trying with the subdomain , I have created the subdomain

    My main domain is like : https://testweb.io Subdomain is : https://testing.testweb.io

    I have added the subdomain at GRPAHQL plugin Settings at wordpress but still cookie is not shared.

    Please check this, I added the subdomain at CORS plugin Here I added the cookie domain

    Both are not working ,please suggest how do i share the cookie with subdomain??


  2. You’re trying to share cookies between origins. You Can’t Do Thatâ„¢. You need to find some other way to share state.

    An origin is a server. Examples of origins include https://stackoverflow.com/, http://example.com/, http://localhost/, and the ones you mentioned.

    The documentation for cookies says

    The domain must match the domain of the JavaScript origin. Setting cookies to foreign domains will be silently ignored.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search