Jump to content

Get cookie values from another domain


emin

Recommended Posts

Hi

Cookie value can be retrieved from same domain using this code, but I need to get cookie values from another domain. Since my app will serve as a subdomain and when the app is created I have to pick the same language as the main domain by getting the language cookies of the main domain.

Quote

UniApplication.Cookies.Values['xxx'];

 

Link to comment
Share on other sites

3 hours ago, emin said:

Hi

Cookie value can be retrieved from same domain using this code, but I need to get cookie values from another domain. Since my app will serve as a subdomain and when the app is created I have to pick the same language as the main domain by getting the language cookies of the main domain.

 

Hello, try to use java script to get cookie: https://www.w3schools.blog/get-cookie-by-name-javascript-js

UNiSession.AddJS (

'function getCookie(cookieName) {
  let cookie = {};
  document.cookie.split('';'').forEach(function(el) {
    let [key,value] = el.split(''='');
    cookie[key.trim()] = value;
  })
  return cookie[cookieName];
};'

alert (getCookie ('wanted cookie name'))

);

Link to comment
Share on other sites

23 minutes ago, emin said:

I could not find how to enter different domain parameters in this script. For example, how can I get the value of the "ct_timezone" cookie in the domain https://www.w3schools.blog

You can show cookie with javascript in URL of browser like this:

javascript:alert(document.cookie);

but: "You cannot get cookies from another site; you can only give own cookies to another site. document.cookie contains semicolon-separated list of name=vale of the cookies of your own page; you can use that to pass to another site using XHR"

from here:https://stackoverflow.com/questions/26178322/how-to-get-cookie-value-using-url

https://stackoverflow.com/questions/36318866/reading-a-cookie-from-a-different-domain

https://stackoverflow.com/questions/3342140/cross-domain-cookies

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...