Accessing cookies from Wix Code

I am using Wix to host the marketing website that fronts my webapp. The Wix site is on the main domain and the webapp is hosted externally on a subdomain.

I want to redirect users from the marketing website to the webapp if they are already logged in.

The webapp stores logged-in state in a cookie, but I have been unable to work out how to access this cookie in either an HTML module or through Wix Code.

Please let me know how I can do this.

1 Like

You can use the Wix Storage API to get or store an item in local or session storage.


Tal, as web developers, we normally have three storage types available to us, local, session and cookies. The wix-storage API only provides access to local and session, so we cannot, or so it seems, get access to anything stored as a cookie using wix code? The wix-storage api doesn’t seem to provide any way to do this, which is what I think Craig is asking for. I am also in need of accessing cookies.

Furthermore, the document object is not available and can’t be imported, or at least I couldn’t in wix code. Perhaps I am missing something. Usually we access the cookies via document.cookie and then extract the values of each cookie using a call to decodeURIComponent(document.cookie) or something of that nature.

Since I can’t get access to document nor can I get a cookie object similar to the local and session objects provided by wix-storage, how then could Craig or I get access to our user tokens from wix code?

It seems that the wix-storage API is incomplete if it includes both local and session, but not cookies, why the apparently arbitrary omission of cookies?

Sadly if we can’t get access to the cookies, we can’t do nice things like switch users between systems without having them have to login to each system separately. That is a nice thing for users to have and without it we’re seriously considering switching the layout engine to wordpress since this would allow us far more control over the underlying code.

Wix code, it seems, is rather restrictive, and I am not seeing any upsides of it being so. So, if it’s impossible to access cookies using wix code, please can you tell us so we can weigh up if using wix code is worth it or if we should move to another platform?



totally true. I am trying to get gclid from cookies and it cannot seem to happen. This is the worst platform I am experiencing

I have figured a way out of this. If someone needs help please refer.

Old post from 2018 being closed.