Swift + Alamofire: User Login & MySQL

Hi @Farhad33,

Thanks for pointing this out, I should have probably made it a bit clearer.

The two MySQL examples require a user to have logged in and created a session, that is what the log in function does. If you store the value returned as the session token then you can reuse this in the other functions. So in the log in function you would store the token like this:

 if let key = post["session_id"].string {
          sessionToken = key
           //At this point the user should have authenticated, store the session id and use it as you wish
  }

You will have to create the sessionToken variable at the top of the class, I haven’t included that here.

Sam

1 Like