-1

How do I code a simple login/registration page that has an option for users to first try it out for 3 days and then after that the session expires and the page can no longer accessible even if users are logged in without first paying a monthly subscription.

2
  • You need to save the time they registered, and check it against the actual time.
    – gen_Eric
    Dec 5, 2012 at 17:28
  • @RocketHazmat can I just do that with a session without using a database?
    – anagnam
    Dec 5, 2012 at 17:34

2 Answers 2

4

You need to store in your database the date the user registered on your application. Then when he accesses your website you verify when this user registered and if it's been more than X days you display a specific message asking him to pay subscription.

1

One way to force them to be logged out after 3 days is to use a a cookie that expires in 3 days. If you are really paranoid about being circumventing this (which is possible), you could store their created time on their user account, and have a simple init() function that gets executed every time a page loads to see if their account was created more than 3 days ago

The second scenario assumes you are using sessions to store the login. The session would be destroyed anyway when the user closes the browser, but if for whatever reason they decided to leave their browser open indefinitely this would destroy it anyway. You would obviously also just check on login

Not the answer you're looking for? Browse other questions tagged or ask your own question.