You are viewing our Forum Archives. To view or take place in current topics click here.
PHP Help.... Stupid Chars
Posted:

PHP Help.... Stupid CharsPosted:

Matthew-
  • Summer 2020
Status: Offline
Joined: Mar 26, 201113Year Member
Posts: 1,881
Reputation Power: 1065
Status: Offline
Joined: Mar 26, 201113Year Member
Posts: 1,881
Reputation Power: 1065
So I'm wanting to limit a page from users on my website so they can only visit the page once per week,

I have no clue where to start but I just need a head in the right direction....

Will +rep as much as I can and help out in any other way if someone can assist me.

Thanks.
#2. Posted:
CriticaI
  • Blind Luck
Status: Offline
Joined: Nov 05, 201310Year Member
Posts: 2,737
Reputation Power: 448
Status: Offline
Joined: Nov 05, 201310Year Member
Posts: 2,737
Reputation Power: 448
store a date in the users' session. check to see if there is a date in the session. if there is then make sure it's a week old. if it is a week old or there isn't a date in the session then display content on the page. and set a new time in the session.
#3. Posted:
iyop45
  • Prospect
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
CriticaI wrote store a date in the users' session. check to see if there is a date in the session. if there is then make sure it's a week old. if it is a week old or there isn't a date in the session then display content on the page. and set a new time in the session.


The user could clear their cookies, and hence any association with that particular session, and then keep viewing the page.

A more appropriate solution would be to make the page only visible by users who are logged in. Then add an extra table to log when any given user has viewed the page.
| id | user_id | datetime |
#4. Posted:
Cyimking
  • V5 Launch
Status: Offline
Joined: May 02, 201211Year Member
Posts: 1,129
Reputation Power: 34
Status: Offline
Joined: May 02, 201211Year Member
Posts: 1,129
Reputation Power: 34
Incorrect. If the session info (token and last login date) are stored in the DB, merely compare the current date against the last login date. If it's less than a week, show error message.

You are thinking about client-side cookies vs. server-side sessions.


Last edited by Cyimking ; edited 1 time in total
#5. Posted:
iyop45
  • Prospect
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Apologies, I misread Critical's post. Specificially the point on "or there isn't a date in the session".

I wasn't getting muddled up; I just misread Critical's post. The session ID is stored in a cookie which associates the user with the session and so clearing cookies will dissociates the user.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.