-3

I develop website and want to remember visitor already vote for my site like this website.

After i research, evercookie is a method to remember visitor.

In the website they protect only once they can vote on a song, even they clear standard cookie, use others browser...

Question: Can it's have other methods to remember beside of evercookie?

Chandara Sam
  • 331
  • 3
  • 7
  • 19

1 Answers1

2

A simple method, store a session variable.
On top of page:

<?php
session_start();
$_SESSION['hasVoted'] = "No";
?>

then in youre code:

<?php
   if( $_SESSION['hasVoted'] == "No")
     {
        $_SESSION['hasVoted'] = "Yes"; 

        //Here goes youre code for submitting the vote.
     }
?>

The downside: when session has been lost, the user can vote again.
Another way is by using a database to store the users IP adress.

using $_SERVER['REMOTE_ADDR'] you can get the viewers ip adress and store that in your DataBase.

Hope this helps.

Nick Prozee
  • 2,823
  • 4
  • 22
  • 49
  • $_SERVER['REMOTE_ADDR'] show the same IP on the same network even on difference computer – Chandara Sam Apr 28 '14 at 09:46
  • Yes, there is a downside to them, but if you want to avoid using cookies then those are a workaround. – Nick Prozee Apr 28 '14 at 09:50
  • You could also force people to create a account first – Nick Prozee Apr 28 '14 at 09:51
  • make visitor friendly, and it just a vote no need them to register – Chandara Sam Apr 28 '14 at 09:53
  • Then you should use a cookie, but still, if they clear all browser data and cookies. They can vote again. Without a login its hard to register since we cannot get Mac Adresses from the computer. I advise you to use the Session. If the answer above is what you are looking for, Please mark as answer – Nick Prozee Apr 28 '14 at 11:20