Michael Crowley
Michael Crowley

Reputation: 63

What's the best way to store session ID in iOS?

I'm building an iOS app version of a web app and I need to store the session ID that is returned after a user logs in. All other information that I need is not sensitive, so I'm going to store it in NSUserDefaults, but the session ID is the one sensitive piece of information I can't store in NSUserDefaults. What's the best way to store the session ID?

Upvotes: 4

Views: 2684

Answers (3)

iCaramba
iCaramba

Reputation: 2640

You can store the session id in NSUserDefaults, it's OK because it is visible to the user as a cookie as well. You can also just store the session cookie as a cookie. If you really want to store it safely you can use the keychain.

Upvotes: 0

benhameen
benhameen

Reputation: 1428

Why, in the iOS Keychain of course!

iOS Keychain Services

There are many libraries that help with this task, one of the most commonly used is SSKeychain. Although, you could also read the documentation and figure out how to do it yourself, or reference Apple's examples as a way of doing this.

links valid as of June 3rd, 2015

Upvotes: 3

Andre Cytryn
Andre Cytryn

Reputation: 2705

It is pretty secure to store session ID in NSUserDefaults. No other apps can access that.

Although this information can be obtained if you connect the device.

For a more secure way you can always use the built-in keychain access to store the sensitive data

Upvotes: 2

Related Questions