Guest user delete comment I'm building an e-commerce site. Users don't have to register, they can buy products without registering on the site, they can leave some comments on each products. I would like that anonymous users could remove their comments . But they are not in the database, so i don't know how to retrieve an unregistered user comments and delete them. Is there a way to do this . I'm not a pro on laravel. Thanks for your help
Unless you have some way to reference them, you can't.
Do you collect any other information at all about them when make the comment?
It's not an ideal way to do it but you could attach an IP address to the comment and check that when they try to delete it.
Noone should be authorised to delete anonymous comments, since you don't actually have a way to know who created them.
@Snapey i understand , i just want an anonymous user to deleted its own comment, not others
and what determines uniqueness of the anonymous ?
@rin4ik nothing i guess :) , i was thinking there was a magic solution in laravel to handle all that
You could give them a cookie which was containing an array referencing their comments.
If the client presents the cookie, and you find reference to a comment in it then you can offer the visitor the option to edit or remove the comment.
They will only be able to do this on the same device that they created the comment on
You can even take this one step further.
Save an 'JWT' in the cookie, so noone can simply alter the cookie to remove all of the comments. Far from perfect but better than plain text.
https://jwt.io/introduction/
Please sign in or create an account to participate in this conversation.