How to store cookie values ​​on an Android device using Phonegap and jQuery Mobile?

I am developing an application using jQuery1.6.1, Phonegap 1.5 (cordova-1.5.0.js), jQuery Mobile 1.0.1 and the cookie plugin (jquery.cookies.2.2.0.js) on Android.

I want to set cookies on one page and want to access the same cookies on another page.

Install

$.cookies.set('sample', 'Cookies_Value'); 

Receive

  $.cookies.get('sample'); 

When accessing the application on the device, I cannot set and receive cookie values. Is there any other way to store cookies on the device?

+4
source share
4 answers

I tested the same applications in different versions of the emulator.

I can store cookies in Android 2.2. But it does not work on Android 4.0.3.

As I understand it, the latest version of Android (Android 4.0.3) does not support.

0
source

You cannot use cookies with PhoneGap / Cordova on Android, so I suggest localStorage instead.

It is so simple:

  • Setting the value: window.localStorage.setItem("sample", "value");
  • Getting the value: window.localStorage.getItem("sample");
+2
source

I don't think Phonegap provides functions for storing cookies.

As you are already using jQuery. You can see the plugin below.

https://github.com/carhartl/jquery-cookie

I hope for this help.

0
source

On the first html page after logging in (I suppose you need to log in) ..... using javascript write document.cookie = ""; .. it will be transmitted for each web page that will be called later.

0
source

All Articles