I want to make a function using php, where guests can add posts to their favorites (so no signup is needed). I tried using MySQL but I got to a dead end because I couldn't find a way to determine a unique device. Some people have told me that I can do the same thing using cookies, can anyone tell me how?
            Asked
            
        
        
            Active
            
        
            Viewed 2,982 times
        
    1
            
            
        - 
                    2i wouldn't bother with out a login system, what happens when the user deletes cookie – Dec 15 '13 at 22:37
 - 
                    if javascript is an option: http://stackoverflow.com/questions/3024745/cross-browser-bookmark-add-to-favorites-javascript – hammus Dec 15 '13 at 22:38
 - 
                    You could set a cookie upon first visit with a unique id? You could then use MySQL and link the unique id in the cookie to a favourited item. You can't do anything about people that clear their cookies, though. – Floris Dec 15 '13 at 22:40
 - 
                    I'd also look into using the browser local storage mechanism, downside is the only way to consume this data is via Javascript (meaning you don't get a nice cookie sent with the request), but it does increase your storage capacity, and less "noise" with every page request sent to the server. https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage – Scuzzy Dec 15 '13 at 22:48
 
1 Answers
4
            - User clicks "favorite this post" button/link
 - Using PHP you set the cookie containing favorited post id, along with the already favorites id's that might have been there.
 - On the "your favorite posts" page you retrieve the cookie and query the database for the id's.
 
        Te Ko
        
- 768
 - 3
 - 13