• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array in Cookie  RSS feed

 
Andreas Jansson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have worked in PHP until recently, but have started to deveolp apps in Java instead.
I have a rather easy (yes or no) question.
Is it possible in Java, to store an Array in a cookie?

In PHP one can put:



Can you do the same in java, or can you put only one value in a cookie.

Thanks in advance.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cookies are text formatted like key - value pairs.
So if you have an array like

String [] myArray = {"one" , "two" , "three"};
then you can have a cookie like

key = myArray and value as "one:two:three"

and again while processing this cookie you can convert his back to an arrry by splitting the value string using : as the delimeter.
 
Andreas Jansson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks.
I guess the easy answer to my question is no, then.
I will try to do it as you suggested.
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd rather answering yes, because:




Edit: PHP string literal quotes (') replaced by Java's one (")
[ January 29, 2007: Message edited by: D Rog ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!