You probably need it stored in db. If they logout and re login then they can just vote again.
There are several S.O. articles and some previous Laracasts post that talked about this very same topic.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am creating a quick voting system for my posts and I have a question about tracking users. I don't want to store their ips in my votes database to ensure they only vote once so I assumed I would use the session. I see that the session "_token": "QFcYtdVv7KcddqB2PHNFp2vcdcp6k6LRTkr2iDS4W", doesn't change unless I load an incognito window. How do I use that token to ensure only one vote per session? It seems like overkill to save that token to a database.
Don't check IP address if there is a chance multiple people at the same company might want to vote.
Just write a 'voted' variable into the session and check it each time.
If you don't want it bulletproof, this can be quite simple, but if they vote then they could vote again once the session is renewed.
if (! session()->has('voted')) {
// not voted. Store the vote
session(['voted' => true]);
}
You can also use the session()->has('voted') in a blade @if statement to disable the button
Please or to participate in this conversation.