Reputation: 11
I have a video streaming website, PHP, MySQL.
I want users to be able to create a unique ID (if they want) and never have to log in again. So every time after they visit the website from then on out they are automatically given their unique session. So they can create play lists, mark favorites, etc and get back to them in the future or show friends.
IP could change.
Network MAC address?
Can anyone provide thoughts on how I can accomplish this? Obviously I need to store in MySQL for the future visits.
Upvotes: 1
Views: 1051
Reputation: 154643
Sadly, you can't get the MAC address with PHP alone.
I used to work in a company directed towards direct marketing, so we had to profile every user action (even the anonymous ones), what we ended up doing was tracking the user using their session ID and using negative ID for anonymous users and a a positive ID for registered ones:
$new_guest_id = SELECT MIN(0, `id`) - 1 AS `id` FROM `users`;
$new_registered_id = SELECT MAX(0, `id`) + 1 AS `id` FROM `users`;
The negative user IDs would then be cleared from time to time using a CRON job:
DELETE FROM `users` WHERE `id` < 0 AND `date` <= DATE_SUB(CURDATE(), INTERVAL 7 DAY);
Upvotes: 0
Reputation: 73035
If you were going for this, one way would be to use something like detecting IP, screen-size, fonts etc, then store that, and assume if 90% is the same, it's the same person.
http://panopticlick.eff.org/ has a demo of the data avaliable (albiet in a different context).
Another way would be to use a combo of cookies, localstorage, flash cookies etc, and to check that. A demo of that would be http://samy.pl/evercookie/, it's a pretty invasive way to do it though, as the user can never delete the cookie.
Upvotes: 1
Reputation: 14951
There is nothing you can do to accurately detect that the previous visitor is the same as the one visiting now. That being said, your best bet is using cookies.
Ip can change, MAC Address can't be retrieved. And cookies can be deleted.
Nothing very secure for storing and presenting their data..unless you let them create an account (or use something like oAuth etc.).
This does also eliminate the problem that they wouldn't be able to view their stored information on other computers.
Upvotes: 1