0

I have an app written in asp.net mvc on domain-A.com and there is an other external service on domain-B.com that will eventually redirect user to my app. But since i have some performance issues i want my app to be ready before redirection to my site and cache some data. So domain-B call one endpoint from domain-A.com and domain-A.com sets a session cookie or any other cookie for itself(not for domain-B.com this is important) and when redirection happens domain-A.com reads cookie for itself and does its staff. Is this possible and if it is what is the method for it.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
cagatay
  • 53
  • 3

2 Answers2

0

Your question isn't very clear. If you are trying to cache some static data for your application in the browser, then I suggest you look into using local storage:

Here are just a few pointers for the start: http://www.w3schools.com/html/html5_webstorage.asp https://www.smashingmagazine.com/2010/10/local-storage-and-how-to-use-it/

On the other hand, you can easily set cookies using javascript code, so I don't understand what you are struggling with.

There are a couple of words that you have used in your post, which makes me wonder... first one is 'Session cookie'. Now 'Session' is a different story. Are you referring to browser session? Application session? Are you trying to share the same session between different domains?

The second questionable phrase is "one endpoint from domain A". What exactly is this endpoint? Are you referring to a WCF endpoint? A web page?

I think you need to provide more details on your post to get proper answer :)

Sparrow
  • 2,548
  • 1
  • 24
  • 28
  • If you can show how to "easily set cookies using javascript code" when script runs on page on "domain-b" and cookies should be set on "domain-a" (which presumably not parent of "domain-b") than this will be actually useful answer... – Alexei Levenkov Aug 18 '16 at 22:18
  • Note that you've obviously use answer as comment - feel free to delete it or convert to actual answer and remove all "Your question isn't very clear" and like text from it. – Alexei Levenkov Aug 18 '16 at 22:20
  • thanks for your answer, i am not trying to share sesssion between two applications and i am referring to server application session not browser's. by session cookie i meant asp.net session cookie and an endpoint is a web service endpoint (like domain-a.com/thisuserwillcometoyou) – cagatay Aug 18 '16 at 23:04
  • Alexei, I have just started answering question in stack overflow and my reputation is very low. The site won't let me to start with a comment because I need 50 points. That's why I had to put my comment in the 'Answer' box. Bottom line is...I have been trying to help someone the best way I could. – Sparrow Aug 19 '16 at 16:14
0

You can't set cookies via AJAX on other domains.

What you can do is to render some page from "domain-a" in hidden IFrame and let it set cookies/cache whatever you want.

Note: this will likely simply double time needed for your site to render. Solving actual performance problems will likely provide better user experience.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • Thanks for your answer it is good to know that i cant set cookie via ajax call now i wont research more about it. I will try the iframe. – cagatay Aug 18 '16 at 22:47