Answer the question
In order to leave comments, you need to log in
"Like" button without authorization?
Hello! There is a task to make a "Like" button under the record, without authorization. I am doing with ajax.
When you click on the "I like" button, the user is given a cookie, and I check that if this cookie exists, then I add a class to the template (the class changes the color of the icon to red), and when clicked again, the counter decreases. The problem is that if you like 1 post, this cookie is created and a class is added (everything is ok, it should be), but when you go to another article, it is already marked as liked (that is, the class is specified, and the icon is highlighted in red), and if you click on the button, the counter will change to - 1
in the template looks like this
class = "@if(Cookie::get('like')) like-active @endif"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question