I am making an ajax call from an html page (mobile) to a .net server for a login and authentication. Right now i am sending back a JSON response with success:true. This all works fine but I need to set the cookies so that the user is remembered when I make other calls to record data once logged in.
I read about using JSONP, but I would rather not go that route if I don’t have to since it means changing a lot. I would like to just send the cookie back in the response and set it manually on the client side.
How do I retrieve this cookie (or create the cookie?” on the server side in .net and send it back in the response?
In your
successevent of ajax, you can set the cookie in client sideAssuming your
JSONis like thisAnd in your ajax function, check the JSON and if the success item value is true, set the cookie.
The SetCookie function sets the cookie.