Search Unity

PlayerPrefs = Cookies?

Discussion in 'Editor & General Support' started by milkytreat, Feb 22, 2007.

  1. milkytreat

    milkytreat

    Joined:
    Jan 15, 2007
    Posts:
    267
    Im looking for a way to store data on a users computer for a site - even if its just for one runtime session. Much like a cookie or a php session.

    I was wondering if PlayerPref's can be used by a web player.
    If so Are there any issues with PlayerPref's if LoadUnityWeb is used?
    Is it possible to transfer data from one gameworld to the next?

    I have tried using php sessions, which I managed to get working but required use of javascripts XML-RPC(ajax) and communication between unity and javascript. And whilst it worked for me its not guaranteed to work on all browsers and machines.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
  3. milkytreat

    milkytreat

    Joined:
    Jan 15, 2007
    Posts:
    267
    starmanta = jesus

    thank-you!
     
  4. grobm

    grobm

    Joined:
    Aug 15, 2005
    Posts:
    217
    Ok,

    I give up. Is there a CookieCutter or other tutorial for the web-player and cookies?

    I followed the steps from the Archive but I keep getting an error. Suggestions?

    My Sample project:
    http://www.markgrob.com/cookiemonster/CookieTesting.zip

    I am becoming a Cookie Monster over this.

    -Mark
     
  5. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    I'm not quite sure how PHP sessions are implemented, but I suspect it's via an unholy combination of cookies and some dodgy attempt to id clients based on IP address, user agent, etc. (if the browser doesn't support cookies).

    AJAX is going to work on all the browsers you care about. Anyone using a browser that doesn't support AJAX is probably (a) not running Unity, and (b) probably experiencing so much stuff not working, that your game not working is hardly going to come as a shock.

    AJAX is fully supported by KHTML/Webkit-based browsers (such as Safari), IE (of course), Gecko-based browsers (such as FireFox, Mozilla, and Camino), and Opera.

    Pretty much the only browsers that won't support it are either running on machines that won't run Unity OR have had JavaScript support explicitly disabled. Again, anyone who does this is hardly going to run some unverified plugin from a tiny company.

    For the 0.01% of potential customers you may lose, here's a workaround:

    Code (csharp):
    1. <noscript>
    2. <h1>You might consider enabling JavaScript if you want to play games online, bonehead.</h1>
    3. </noscript>