views:

132

answers:

1

I'm trying to make a vote/poll application in Flash using Actionscript 3. Is there any way to generate a specific ID that is unique to each user? The only other option I can think of is using the IP address, which is less than ideal in many cases (college campuses, shared Internet access, etc.). It needs to be the same number every time it is run on the same PC, but different for each user.

+1  A: 

You have two options:

1) A Remote Shared Object, which is a fancy way to say a Flash Cookie, which will remember the browser every time.

Alternately, you can set up some sort of back-end login system (since you want unique to every user, even on the same computer, this sounds like what you'll have to do). This is more than just flash - you'll need to integrate with a server-side scripting language like PHP (integration is easy with AMFPHP or ZendAMF, I believe you can find some tutorials on http://www.gotoandlearn.com) and handle your user stuff there.

You're going to have to wire this up to some sort of login - there has to be a way for users to identify themselves, or the whole thing is pointless.

If I were you I'd put a login screen first, tie to a PHP back-end and use cookies to remember that you have someone logged in - but give them the option to log out. Then you simply associate the logged-in user with some sort of unique key - like the user index in a MySQL database - and you're all set.

Depending on how comfortable you are with technologies beyond flash that may either sound simple or complicated, but it really shouldn't take you too long. If you don't know anything about PHP or MySQL you can google "PHP User Login" and that should get you started. Let me know if you have any specific questions!

Myk
I think I'm going to go with a combination of IP address and Flash Cookie. Can flash cookies be "cleared" like regular cookies?
VGambit
@Myk. I think you meant a *Local* Shared Object. Also, local shared objects are not managed by the browser, but by the player. So you can use different browsers to access the same swf, but the LSO data will be shared among them (as long as you access them through the same domain).
Juan Pablo Califano
@VGambit. No, they are not managed by the broswer. A user can delete these files by hand (but most users wouldn't know how to find them in the first place). There are some plugins to make it easier to purge LSOs, I think, though I never actually used one.
Juan Pablo Califano
@Juan you're right, thanks for clarifying. Also, with respect to clearing flash cookies: Flash Player 10.1 now links your privacy settings to your browser, so for instance if you are using private browsing the flash cookies are not saved. I'm not sure if they're going so far as to link it to clearing out the cache and removing cookies, though - probably not.
Myk