Jump to content

Cross-Domain Cookies/LocalStorage in Jquery


Recommended Posts

I'm developing a Third Party Login System (Oauth) like facebook developers and I need to set cookies multiple domains (depends on how many domains user specifies). So I need to set cookies to all the domains a user specifies using jquery, I've tried everything but none has worked. All I found is "create an iframe","use ajax to set a cookie across multiple domains" but they will not work in my case because, it will need the user to create a html for the iframe or a php file for ajax request that I don't want to do. What I want to do is let the user include the Jquery SDK and allow the user to make requests and to make requests SDK will set cookies so I need to use a cookie for all the specified domains.

Here is the flow of how it works:

It've two initialization methods "NM.init()" & "NM.login.init()"

First of all, user calls NM.init() to set his/her App ID & App Secret. (Here the SDK uses cookies to set the App ID and Secret for every domain configured in the app)

Then, user calls NM.login.init() to set the fields he/she wants to retrieve. (Here the SDK uses cookies to set the Fields for every domain configured in the app)

After that, user calls NM.login.request() to retrieve the fields he/he set in NM.login.init(). (He can call NM.login.request() either from the same page/domain where he/she called NM.init() and NM.login.init() or from any other page/domain).

In case if user calls NM.login.request from another domain, it needed to get the cookies set on other domain.

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...