Image 'DRM'

phpnutphpnut Junior MemberShared Hoster
I'm trying to come up with a way for users to have a 30-day pass to some images on my site, but am having a hard time thinking of how to do it. I already know how to put images in a database and retrieve them, but can't figure out how to tell if their 30 days is up. I know the date() function won't work... what will?
My ongoing projects...
www.naturesmagazine.com
www.energyreform.org *new domain*
www.photographyavenue.com
----
You may also remember me as imnewtophp...

Comments

  • LurkinBackLurkinBack Senior Member The Royal RAM
    In SQL I use a functon called Datediff(dt,'d',30). This basically takes the date given to it(dt) and moves the date on or back a set amount of time(30), 'd' is what to move it by days/months/years. I dunno if it exists in MySql but if it does just use that to take the date you have for it beginning on file and add 30 to it then check to see if it's today :D
  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    The easiest way I can think of would be to use cookies.
    What you'd need to do is create a cookie on the users system which holds the date that they first accessed the image.
    In your script, you could then pull up this cookie and compare it with the current date information, meaning you could work out how long it's been before they first accessed the script that shows the image.
    The problem here is that cookies aren't perfect and can be deleted and toyed with.
    If the cookie is deleted, the user is basically granted an entirely new 30 day access period.
    You could store some data in a database to tell the script when that user first accessed the script with a cookie containing the user I.D., though you'd have to remove the data from the database whenever the user requests a new 30 day access period, meaning there's more work envolved.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
  • xPureNLxxPureNLx Moderator The Royal RAM
    Won't sessions work?

    - xPureNLx
    signaru02am7.jpg
    [B]MSN: xPureNLx@gmail.com[/B]
    
  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    No.
    Sessions are destroyed when you log off.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
Sign In or Register to comment.