Chrisj Posted April 10, 2019 Share Posted April 10, 2019 I'm trying to create a cookie where the visitor who uploads a webcam recording, from the webcam recording web page, can't record and upload until X amount of time has passed. I've searched around and have gotten this far: document.cookie = "name=Recording_Time_Delay; expires=5 minutes; path=/"; function create_cookie(Recording_Time_Delay, Start Disabled) { var date = new Date(); date.setTime(date.getTime() + (minutes * 60 * 1000)); var expires = date.toUTCString(); document.cookie = name + '=' + value + ';' + 'expires=' + expires + ';' ; } It will be added to the script shown here: Ultimately, I'd like someone not to be able to record/upload until 5 minutes has elapsed from the last upload. Currently, when a recording is uploaded the User is redirected to another page. If they come right back from that redirect and record/upload again, I'd like that ability to be unavailable/delayed. I would image the time out should start upon the initial recording being uploaded, where a 5 minute delay starts, and disables the Start Recording function (or button)? Does that sound right? And what am I missing in my cookie code attempt? Also, how do I tie in the disable Start Recording function/Button? Any guidance will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/308578-help-with-creating-a-cookie/ Share on other sites More sharing options...
requinix Posted April 10, 2019 Share Posted April 10, 2019 (edited) 1 hour ago, Chrisj said: I would image the time out should start upon the initial recording being uploaded, where a 5 minute delay starts, and disables the Start Recording function (or button)? Does that sound right? Is that what you want it to do, or not? Quote And what am I missing in my cookie code attempt? The first lien line that sets the cookie is probably wrong, and the function isn't being called. Quote Also, how do I tie in the disable Start Recording function/Button? You'd check for the cookie before letting the user click, and then also check the cookie in your PHP in case the user got around the Javascript block and recorded and uploaded anyways. Edited April 10, 2019 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/308578-help-with-creating-a-cookie/#findComment-1566016 Share on other sites More sharing options...
Chrisj Posted April 10, 2019 Author Share Posted April 10, 2019 Thanks for your reply. Yes, it should disable the Start Recording button (for 5 minutes) upon the upload completing. Any additional guidance with 'setting the cookie' and 'calling the function' and 'checking the cookie before letting the user click' would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/308578-help-with-creating-a-cookie/#findComment-1566017 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.