0

I have a backbone marionette application that makes REST api calls.

In my model when i make a api call to login i get a session value back and see the cookie being set in the browser

immediately after when i make another call to get the user information that is logged in i receive a different session or cookie value and no user is found. CORS is enabled and options calls are being made.

When i hook up the api to my other applications that were build off non backbone libraries it works fine. Does anyone know how to solve this?

Here is my post

         doLogin: function( data ){

            this.fetch({
                data: JSON.stringify(data),
                type: 'POST',
                contentType: 'application/json',


                error:(function (e) {
                    alert('error');
                })
            });

        },
Yeak
  • 2,470
  • 9
  • 45
  • 71

1 Answers1

0

It is not clear on this piece of code but looks like your calls are going to different domains (once you mentioned CORS).

If that is really the case, I am afraid session and cookie might be different because they are probably specific only to the domain that your 1st request (doLogin) reached but not the 2nd request (fetch). More info: Sharing cookies across different domains and different applications (classic ASP and ASP.NET)

Another thing to look is if your both servers REALLY support CORS because one part of the setup is client-side and another is server-side (headers). More info on: http://www.html5rocks.com/en/tutorials/cors/

Community
  • 1
  • 1
Tiago Romero Garcia
  • 1,068
  • 9
  • 11