user1313236
user1313236

Reputation: 53

can't set value for cookie

Sry for my english. I create a simple app on my Android smartphone. That app has to replace cookie from one site into the cookie with different value, but other parametres has to be the same. So I got that Cookie that way:

Cookie c = httpclient.getCookieStore().getCookies().get(0);

Now I want to change value. The problem begins here, because I can't use method like this:

c.setValue(newValue);

I keep getting error "The method setValue(String) is undefined for the type Cookie", nevertheless I saw examples of using that method in various codes, for example here: http://www.javadrive.jp/servlet/cookie/index4.html. What am I doing wrong? Please explain it to me clearly, cuz I am rather Java newbie. Thanks

Upvotes: 2

Views: 642

Answers (1)

nicholas.hauschild
nicholas.hauschild

Reputation: 42834

The Cookie interface does not define any setXXX() methods. You will need to create a new instance of the Cookie to change its state (or else you can cast it, but that would require that you know its underlying type).

Perhaps you should consider creating an instance of BasicClientCookie and setting up its state to be the state of the cookie to be the same as the cookie you already have except for the value, which you want to change.

Upvotes: 1

Related Questions