How to set cookie in opera mobile?

Forums » Dev.Opera » General Web Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

17. May 2010, 11:23:32

amsterdamharu

Posts: 4

How to set cookie in opera mobile?

I tested with opera mobile for Linux using dragon fly on opera 10.10 for linux and am unable to set a cookie.
Note that opera mobile for Linux has a privacy setting to allow or disallow cookies and I allowed cookies. I could not find the same thing on my windows mobile version of opera mobile.

Script did not produce an error so I set a breakpoint and go to command line, here is the output:

>>> value="hello"
"hello"
>>> document.cookie=name+"="+escape(value)+expires;
"lessonName=hello; expires=Sat, 22 May 2010 09:59:37 GMT"
>>> document.cookie
""
>>> document.cookie=name+"="+escape(value)+"; expires=01/01/2011 00:00:00"
"lessonName=hello; expires=01/01/2011 00:00:00"
>>> document.cookie
""

Setting the cookie to: "lessonName=hello; expires=Sat, 22 May 2010 09:59:37 GMT"
gets me an empty string when asking for document.cookie
Setting the cookie to: "lessonName=hello; expires=01/01/2011 00:00:00"
same empty string.

This works in desktop browsers but not in opera mobile, tried on my windows mobile and get the following output:
document.cookie="mytest=hello; expires=Sat, 22 May 2010 09:59:37 GMT";
alert("cookie is:"+document.cookie+":empty is it?");
document.cookie="mytest=hello; expires=01/01/2011 00:00:00";
alert("cookie is:"+document.cookie+":empty is it?");

Result is an empty cookie twice (cookie is::empty is it?).

So here is the question: how do I set a cookie on opera mobile?

Just a little update I set the enable cookies to 3 when opening the opera:config page that should accept all cookies.

Forums » Dev.Opera » General Web Development Discussions