Forum Academy Marketplace Showcase Pricing Features

Limiting some actions to be possible once per session (cookies?)

In a voting app customers need to be able to like some options once per session. How to identify visitors that don’t have an account? I need something like:

Solution A:
VotableItem

variable votedVisitors as a list of **session ID-**s (or something else that would help identify them)
When user votes his ID would be added to the votedVisitors and he wouldnt be abled to vote again.

Solution B:
Alternatively I considered creating automatic accounts for each visitor, something like [email protected]. That would identify them enough. How to generate a random email? Or a random number that I can convert to a string and use it as an email? How to add 2 strings together?

The current user exists if the user isn’t logged in, so you can use the unique id for instance. It will be the same user until the user cleans his cookies. If he signs up, we use the same user id, and make it a real, signed up user.