0

I forgot to put session command when I built first version of an iPhone application. Now, I wrote a session check command in every PHP function.

However, the first version is not working well because it loses session sometimes. A lot of people are using the first version already and can't change it at this moment.

So, I was thinking that if I can get udid value of iPhone by using php command, I get give them a new session value who lose session data. or is there other solution to make this happen?

Thank you.

james
  • 225
  • 6
  • 20
  • http://stackoverflow.com/questions/2072240/read-udid-from-iphone-with-javascript-on-mobile-safari Apple moved away from giving developers access to device identifiers. – ta.speot.is May 16 '12 at 12:25

1 Answers1

0

You can send udid from iphone using webservice to php and then you can access it.

 NSString *token=[NSString stringWithFormat:@"%@",deviceToken];
token= [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
token= [token stringByReplacingOccurrencesOfString:@">" withString:@""];
token= [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *post = [NSString stringWithFormat:@"token=%@",token];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.server.com/web-service/save-token.php?"]]];
 [request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnstring = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Ronak
  • 974
  • 6
  • 14