merck_delmoro Posted May 6, 2009 Share Posted May 6, 2009 Can you give me some advise how to do it???? or some sample codes to help me to build my project Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/ Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 What are you trying to do that requires that? Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828000 Share on other sites More sharing options...
merck_delmoro Posted May 6, 2009 Author Share Posted May 6, 2009 Im trying to make a login page that inserts the username of the user into the database and when it expires the username of the user will be deleted Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828004 Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 Set a timestamp when you set the cookie in the database. If that timestamp is past the date, delete it. This can be done using a Cron job for *nix or Scheduled tasks for Windows. Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828008 Share on other sites More sharing options...
Zane Posted May 6, 2009 Share Posted May 6, 2009 why do you need to delete it? if the timestamp is expired then they just flat out shouldn't be logged in anymore. if you delete your records then what's the point of putting them in there...having all those records are good for statistics and such. Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828013 Share on other sites More sharing options...
merck_delmoro Posted May 6, 2009 Author Share Posted May 6, 2009 im trying to do a webpage that counts how many user is on my site and who they are ... there username will be stored into my database when they are online but when they are not available they will be deleted into my database Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828015 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 You can select users whose accounts are active without deleting anything. Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828018 Share on other sites More sharing options...
merck_delmoro Posted May 6, 2009 Author Share Posted May 6, 2009 I can select all the user that is active that the question is how can I Update the records in the database when they are log-out or the cookie has expired???? Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828031 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Does the cookie being deleted mean it expires as well? If not, then just store the time in the DB when the cookie is to be expired. Then don't worry about the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828034 Share on other sites More sharing options...
Zane Posted May 6, 2009 Share Posted May 6, 2009 check out the onLoad event with JavaScript and use AJAX to do your database thing. EDIT: oops I mean onUnLoad http://www.w3schools.com/jsref/jsref_onunload.asp Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828042 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 How would onunload help? They're cookies, not sessions. o.O Perhaps I missed something? Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828049 Share on other sites More sharing options...
Zane Posted May 6, 2009 Share Posted May 6, 2009 good point, but that raises another question.. does the op really need cookies? in short...there is no function called onCookieExpired (although you can write a cron job for it) but if you use session's you can tell who is active (logged into the page) much easier Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828053 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 Well I guess cookies allow the user to be logged in after they closed the tab or navigated away from it. I'm assuming it's a free trial for x amount of time and he wants the user to only be accounted for those days. Quote Link to comment https://forums.phpfreaks.com/topic/157145-q-how-to-delete-records-in-the-database-when-the-cookie-has-expired/#findComment-828065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.