Get cookie value from other site to my wix site

Hello everyone,
I want to get my jsonwebtoken stored in headers of my Webapplication1 which is build in nodejs is there any way to get that cookie(token)

Anything helpful will be appreciated. Thanks

Not exactly sure what you are trying to do, but you can look at the example Expose and Access Site APIs Example . The sample apps, MyApi and MyApiClient, show how to expose and access external APIs which allows one web site to “talk” to another.

Hi Yisrael,
After recently being notified of someone liking this reply -https://www.wix.com/velo/forum/main/comment/5c28a8600b6be60d5f0e1d03 on a related question to the one asked in the post by usamadanish22 , I was reminded that this is probably the same problem and it seems Wix has not dealt with this.

The problem, I believe is that Velo (Corvid? Missed the name change? I guess potentially having your API associated with a virus wasn’t great for marketing) via its storage API only provides access to local and session storage. Cookies are not accessible, not via the storage APi and also can’t be accessed via the document either since we can’t access the document through Velo? (see -https://www.wix.com/velo/forum/main/comment/5ef055cb5223d00051ceb9c2))

The impact of this is that anyone who has another system on the same domain (like us) cannot use wix unless wix does all the auth since we cannot, using Velo, auth users via an id or auth token stored within their browser. Wix is nice as a CMS, but this inability to read our own auth data from our users document.cookie makes Wix unusable for what we need, and its seems for others as well. It seems the design of Wix assumes that it is the only game in town, which is weird since there are APIs for using external databases on third party services, but nothing for reading cookies from the browser that can help with identifying who is using those services. We have such third party services and databases, but can’t id users on those databases/services due to Velo’s design.

We’re moving to wordpress because of this. Though not just for the technical reason, but also because that after asking this very same question two years ago, not only did we get no reply from the moderator to whom we directly addressed our concerns to, but then the question was closed. I refer you to my first link above for that question.

The outstanding questions still remain, however, which are,

  • how are users like us meant to read cookies from browsers? This is a fundamental feature of serving web services to users, and its not present in Velo.

  • And, if its not going to be implemented, are you at least going to make it abundantly clear in your documentation that this is a limitation, and why you do this. If I have missed such docs, please link to them, I’d be glad to know that they’re there to let others know.

I’m with you, this is just a shame. This is such a basic feature.
How am I supposed to choose Wix over wordpress for example?
It’s like comparing MS Paint to Adobe Photoshop.

@admin81489 This is an old post, but what exactly is it that you want to do? It would be better if you would create a new post explaining what your requirements are and what you have tried so far.

@yisrael-wix I’m just trying to get a cookie value into my wix code so I can send it in my form submission. For example, I have a 1st party cookie named “hubspotutk”. I can clearly see it with my inspect tool:

I just want to get this cookie’s value. I can’t seem to do it, and I can’t seem to find any answers in this forum.

With Google Tag Manager, this would take apx 1 minute to accomplish.

You can use the Custom Element to implement code for accessing (read/write) cookies. In fact, a Custom Element will let you do many things that plain Velo doesn’t allow.

Thanks for your reply, I created a new js file under custom-elements.
What now? It doesn’t look like I can paste my own JS code in there, it’s still working under Wix code’s syntax.

@admin81489 Custom elements are defined using the standard ECMAScript 2015 class syntax. You can put almost anything into a Custom Element. See these simple examples to get started:

For more complex examples, see the Wix Custom Element examples .

Review the custom element documentation and the API for more details.

@yisrael-wix Hi, I’ve looked at your examples. I think this only confused me more.
All I’m trying to do is to create a const with the value of the cookie called " hubspotutk ".

This is the javascript I’m hoping to run when the page loads:

function getCookie(hubspotutk) {
  let name = hubspotutk + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      const hubspotutk = c.substring(name.length, c.length);
      console.log(hubspotutk)
    }
  }
  return "";
}

Hopefully that way, the const called “hubspotutk” will have the value I’m looking for.

As I said, on Google Tag Manager, all I have to do is to create a “1st party cookie” custom variable and type in the cookie’s name, that’s it.
I don’t know why it’s so impossible with Wix.

Isn’t there something similar to local.getItem, but with cookies?

Here’s a very simple example for reading a writing cookies using the Custom Element.

@yisrael-wix setAttribute() has nothing to do with document.cookie … @admin81489 have you figure out?

Anyone have any luck with this?