0

I am building a website that will require the user to enter a zipcode to navigate to any page that is not the home page. The zipcode will be sent to a database via an html form.

Would this be an occasion to use HTML5 local storage?

My idea is to use javascript to capture the zipcode the user enters into the form. When the user navigates to another page I could prevent a page load unless there is a zipcode present in local storage.

There is possibly another option, but I'm not sure it is a good way to go: HTTP Authentication with HTML Forms. This is authentication, but I'm not really looking to authenticate based on a specific username/password. I just want someone to enter a valid zipcode.

These are just some ideas I had on how to accomplish this goal. Would either of these work? Is there an alternative, better way to do this?

Environment: Orchard CMS (.NET MVC)

J7stin
  • 491
  • 1
  • 4
  • 12
  • Pretty easy to do with cookies, just create the cookie when they log their zipcode. Then when they try to go to other pages, just check for the cookie. Take a look at http://stackoverflow.com/questions/2257631/how-create-a-session-using-javascript – JWarren Oct 23 '14 at 21:39
  • Thanks JWarren, I was hoping for a non-cookie solution, but this is a great backup plan. – J7stin Oct 23 '14 at 22:10
  • The non-cookie solution is getting the session id the server assigns to the client, and storing that with the zip code in the db. Then you have to get the id, and query the db for each page load after that. Cookies are a bit easier and faster. – JWarren Oct 23 '14 at 22:13
  • Suggesting you to use [localForage](http://mozilla.github.io/localForage/) – cforcloud Oct 24 '14 at 16:28

0 Answers0