I am sending a $.getJSON
(HTTP GET) request twice (with different data), one after another (lets say we have request1 and request2). I can see in the developer tool
Just store your cookie(with JESSIONID) in Client , when your send subsequent request to Server , put the stored cookie in your request header field and send, then you will get the same session in the server end.
CLIENT(IOS) store your cookie from response:
NSHTTPURLResponse* httpURLReqponse = (NSHTTPURLResponse*) response;
NSDictionary* allHeaders = [httpURLReqponse allHeaderFields];
NSLog(@"Response Headers : %@ ", allHeaders);
NSString* cookie = [allHeaders objectForKey: @"Set-Cookie"];
DATA.cookies = cookie; // Store the cookie
CLIENT(IOS) send your subsequent request with cookie:
// Put the stored cookie in your request header
[(NSMutableURLRequest*)request addValue: DATA.cookies forHTTPHeaderField:@"cookie"];
[NSURLConnection sendAsynchronousRequest: request queue:[NSOperationQueue mainQueue] completionHandler:nil];
Not only for IOS client . Then , in the server end , you will get the same session:
Server(JavaEE) GET HttpSession:
// Get the session, print its hashCode. You will find out that it's same as previous.
HttpSession session = ServletActionContext.getRequest().getSession();