Author Topic: Cookie I/O  (Read 9230 times)

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Cookie I/O
« on: September 27, 2012, 03:23:10 PM »
Hey all,

So I'm in the planning stages of my next project, and I'd like to do it as an applet (I'm a Java programmer).  My reasoning is that it would make updating very easy, and I'd be able to make it accessible to mobile devices while still allowing keyboard input (I'm thinking a button bar on the side; phones are TERRIBLE interfaces for games).

However, I'd like to be able to suspend the game.  In QuickHack (http://roguebasin.roguelikedevelopment.org/index.php/QuickHack), I saved high scores and save files by using text files with a checksum, which was a clean, simple way for me to do things.  I'd like to use cookies to do the same.

Sadly, I've had some trouble finding a decent rundown on how to read and write cookies.  Maybe I just missed a tutorial on the Oracle site.  If any one has any tips, links to tutorials, etc, I'd greatly appreciate it!

Leaf

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Cookie I/O
« Reply #1 on: September 27, 2012, 08:41:59 PM »
http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html

You have to sign your jar for that to work, though, and it may require that the applet be deployed via JNLP rather than the usual applet tags (but I am not sure!).  AFAIK, if you want to access cookies with an unsigned applet, you have to use some JSObject hackery (which will also require you to set "mayscript" in the document where you deploy your applet), which makes it seem a little dumb to not be able to access cookies with an unsigned applet! D:

Robobot

  • Newcomer
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Cookie I/O
« Reply #2 on: September 27, 2012, 11:40:34 PM »
So I'm in the planning stages of my next project, and I'd like to do it as an applet (I'm a Java programmer).  My reasoning is that it would make updating very easy, and I'd be able to make it accessible to mobile devices while still allowing keyboard input (I'm thinking a button bar on the side; phones are TERRIBLE interfaces for games).

Sorry, but which mobile devices support Java-Applets? I don't' know any.

Leaf

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Cookie I/O
« Reply #3 on: September 28, 2012, 02:10:22 AM »
You might be able to compile it all to JavaScript with GWT or something.

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Cookie I/O
« Reply #4 on: September 28, 2012, 05:20:41 PM »
@Robobot: Dag nabbit, I think you're right.  Hmm, not sure if it's worth the extra effort, then.

Robobot

  • Newcomer
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Cookie I/O
« Reply #5 on: September 28, 2012, 08:51:17 PM »
@Robobot: Dag nabbit, I think you're right.  Hmm, not sure if it's worth the extra effort, then.

If you want to code in Java and for the web, Leaf's suggestion of GWT sounds like a good approach. I never used it, but heard a lot of good things about it. You might want to use localStorage instead of cookies though.