1

I am making a local webapp that will have a login page.

I am using PhoneGap to make the app local and I wold like to stash some user data in a cookie or something like that.

So far I have been stashing the username and encrypted password in the cookie, is that very unsafe and what wold be a better and safer way to do this?

Thedtxy
  • 13
  • 3

1 Answers1

0

To respond with better alternatives, I'd like to point you to Stormpath's Auth article and a related StackOverflow question. The Stormpath article has some big name options if you don't like writing this sort of code (I love it.) and the related question has a great answer with examples I'd have stolen otherwise.

I'd love to quote you some snippets to clear things up, but there's a zillion ways to handle implementations. The basic flow is this:

  1. Client passes credentials to Server

  2. Server Authenticates credentials

  3. Server generates a token (UUID, random string, whatever)

  4. Server replies with the requested info and token

  5. Client sends token with the next request

  6. Server matches token to authenticated session

  7. Repeat 4-6 until the session is expired (Logout or timeout)

My own implementations usually continue differently to prevent some other security issues:

  1. Server deprecates the token used by the request

  2. Server generates a new token

  3. Server replies with requested info and new token

  4. Repeat steps 5-9 until the session is expired (Logout or timeout)

Community
  • 1
  • 1
gelliott181
  • 1,008
  • 11
  • 19