This video follows on the previous week's technique. Explore how to use the expiry date stored in the database to set the session variable to control access or to alert the subscriber when renewal is due within one month.
- [David] Hi, I'm David Powers…and welcome to this week's edition of…PHP Tips, Tricks, and Techniques.…Designed to help you become a smarter,…more productive PHP developer.…In the previous two editions,…we looked at using the PHP password hashing API…which offers a more secure method…of encrypting and verifying passwords.…And setting a future date using PHP relative date strings.…Both subjects are useful in their own right…but they also act as a curtain raiser to this question…from a member.…
How can I prevent access when a membership has expired?…Several possible solutions spring to mind.…You could simply delete the member's account…from the database.…Without a username and password,…they could no longer log in.…But that's not a good idea…because you would lose all information about the member,…making reinstatement a hassle if they decide to rejoin.…To avoid losing the member's data,…you could set an inactive flag in the database.…
Again, not a good idea because it involves…manually updating the record.…The simple way is to store the expiry date in the database…
Note: The exercise files are free to all members. The code is commented to enhance your learning, but you will need database connectivity for some files to run as intended.
Skill Level Intermediate
PHP: Managing Persistent Sessionswith David Powers2h 41m Intermediate
New this Week:
1. Weekly Episodes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.