how to allow user comments editable for a few minutes,after which should be made readable
Just want to know the logic behind ,开发者_如何学Python allowing user comments to be editable for a few minutes in the site ,after which should be made readable.I had seen this in linkedin site. My solution to use create session during the comments submission and refresh for every 3 minutes and check whether the session has timed out after 14 minutes through ajax.let me know your solutions.
i need to know the best solution to implement.
Why not simply refuse changes after a certain time? When a comment is made, store a 'changesExpire' date (say, 10m in the future). When you get a change for a comment that's past the 'changesExpire' date, you simply refuse them.
On the UI, you can have a simple countdown timer. Put up an 'edit' button, fire off the timer. When the timer goes off, hide the button.
If you leave the page, no big deal, it all goes away. If you come back, create a new timer that is set to the remaining time in the 'changesExpire' value.
No reason to keep connections open or anything here.
Or you could use long polling (see Comet), and just track time on the server.
Exploiting the session like the above solution is less than ideal.
精彩评论