Currently my iOS app was retrieving data from the server which built using PHP + MYSQL through JSON, then in my PHP I tried to echo the session_id()
. My app was using NSURLConnection sendAsynchronousRequest
to communicate with PHP.
I tried request the same URL for 3 times, the returned session id will be in different value, I had included session_start()
in my PHP as well.
But if I run the URL in browser, no matter how many times I run it the session id will always be the same.
Here is my iOS request code:
NSString *newURL = @"http://www.example.com/index.php?value=getData"];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:newURL]];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
if ([data length] >0 && error == nil){
NSDictionary *myDict = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&error];
NSLog(@"%@", myDict);
}
}];
Please help. Thanks.