ajoo Posted January 30, 2014 Share Posted January 30, 2014 Hi all. I have just created a login page which logs a person into a page with menu buttons. However, i have noticed that if, inadvertently, i double click any of the menu buttons or the other form submit buttons, i get logged out. I think this is because of the session_regenerate_id that i used for the login purpose and which I don't want to change. So I would like to know if there is some way to ignore subsequent clicks for a certain period of time once the button has been clicked. For e.g. if i have clicked a submit button, then i want that any further clicks on the same button be ignored if they occur within say 500ms of the 1st one. Something like that. Or better still if the subsequent clicks are ignored until the previous button action has been completetd once it is clicked. Again for e.g. if i a submit button is accessing a database and takes say 300ms to retrive and display that information, then once that button has been clicked, subsequent clicks on it should be ignored - in this eg. for 300 ms - till the previous button action is complete. Implore all the gurus for their invaluable inputs and guidance. Thanks all ! Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 30, 2014 Share Posted January 30, 2014 Have you looked into something like this: http://www.the-art-of-web.com/javascript/doublesubmit/ Quote Link to comment Share on other sites More sharing options...
ajoo Posted January 30, 2014 Author Share Posted January 30, 2014 Hi thanks cyberRobort. No i have not so I'll take a look atit and revert. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
ajoo Posted January 30, 2014 Author Share Posted January 30, 2014 Hi Ok so i took a quick look at the article and its using javascript which i wanted to avoid since I am mainly using php. Frankly I have tried a similar approach in php by using variables and checking their value just before the button click. In fact the button is supposed to be displayed only if the value is true. <? if isset($button) && ($button==true) ?> <input type = "submit" name = "submit" value = "Submit" > However this does not seem to work. So is there any other way to achieve this without the javascript or is that a must. Thanks again for the reply and definitely looking for some more information on this one. Thanks. Quote Link to comment Share on other sites More sharing options...
davidannis Posted January 30, 2014 Share Posted January 30, 2014 (edited) How about something like this: $stamp=time(); if ($_SESSION['clicktime']<date("Y-m-d H:i:s", $stamp-1)){ $_SESSION['clicktime']=date("Y-m-d H:i:s"); //set the last click time for the next click //do your stuff here }else{ //it was within a second so don't do anything or send a double click message or log it or whatever } Thanks to this post for the idea http://forums.phpfreaks.com/topic/239754-addsubtract-one-second-from-datey-m-d-his/ Edited January 30, 2014 by davidannis Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 31, 2014 Share Posted January 31, 2014 (edited) if someone is getting logged out due to normal/likely user actions, that indicates you have a problem in your code. putting a band-aid over the tail-end of the problem isn't going to fix it. your first step would be to find out exactly what is causing the logout to occur. and based on your thread started after this one, your symptom of the login panel reappearing is likely the symptom of the logout state. fix the problem in this thread, and the other problem will likely go-away. Edited January 31, 2014 by mac_gyver Quote Link to comment 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.