Using cookies...

How to write and read a string into the cookie in Js mode? Is there a way to limit acceess to the string by others?

Answers

    1. You have to use JavaScript code for that.
    2. "by others" is a bit fuzzy. Other sites just cannot see your cookies. But a user can always see the cookies on his browser. At best, you can encrypt its content. Not foolproof for somebody motivated with some programming knowledge...
  • edited April 2015

    I guess my tone was not right... I assumed there was a different method in Processing(meant by "in Js mode") and meant to ask about its safety measures... But i tried document.cookies and it worked fine... Sorry for the inconvineince... @PhiLho could you close this discussion? Dont want it to be hangong around as unanswered...

  • edited April 2015

    But i tried document.cookies and it worked fine...

    • You've just issued a command which only exists in JS mode, breaking Java cross-mode compatibility!
    • It's no big deal if your intention is to deploy to the web only though. :ar!
    • Although in such cases I'd create a ".js" named tab to place JS only codes and call it from the ".pde" tab, just for organization's sake.
    • Another option is to switch for p5*js framework, which is more JS centric than PJS'! *-:)

    http://p5js.org/reference/

  • I rarely close threads not breaking rules.
    I suggest to show a little bit of code illustrating your finding, and to accept your own answer! :-D

  • edited April 2015 Answer ✓

    A complete description on all cookie function(Javascript) are found here. It works for Processing Js mode too... document.cookie is a String variable i guess.

    document.cookie="text you want to save"

    to write. To read use as here

    println(document.cookie)

    Now how do i accept my answer @PhiLho?

Sign In or Register to comment.