python - where to save the verification code sent to the user for signing up -


i'm somehow new django , it's first time implementing signup form sms verification.

i user mobile number , generate random number , send him; want generated code expired after 30 minutes , after don't need them, seems not idea save them in db , after expiration time, delete them.

i wonder if can me the question "what best way implement this?"

thank in advance

save them in redis. redis keys can have ttl(time-to-live), keys ttl deleted automatically after time period.

import redis r = redis.strictredis()  # create pin  r.set("<phone-number>", <sms-pin>) r.expire("<phone-number>", 1800) # 1800 seconds = 1/2 hour  # pin if r.exists("<phone-number>"):     pin=r.get("<phone-number>")     ... validate pin else:     ... invalid pin 

more docs @ http://agiliq.com/blog/2015/03/getting-started-with-redis-py/


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -