beefe / react-native-cookiemanager

22 stars 12 forks source link

cookies are not persistent #2

Open mallikarjunakp opened 8 years ago

mallikarjunakp commented 8 years ago

Hi, I have used the code as you explained. Please check the issue that i am getting.

Here is my code,

var options = { name: 'username', value: 'abcdefg', domain: 'http://localhost:8081/', origin: 'http://localhost:8081/', path: '/', expiration: 'Thu, 18 Dec 2016 12:00:00 UTC', }; CookieManager.default.set(options,(res) => { alert("Set cookie"+res); });

I am executing this on click of a button for testing.

Then i am using the below code to get cookie CookieManager.default.getAll((res) => { alert(JSON.stringify(res)); });

But then the cookie is null. it alerts me this {}

shexiaoheng commented 8 years ago

try change there

CookieManager.default.set(map,(res) => {
alert("Set cookie"+res);
});

to

CookieManager.set(map,(res) => {
alert("Set cookie"+res);
});
mallikarjunakp commented 8 years ago

I have done that before. But it says undefined is not a function evaluating the CookieManager.set And then i debugged and consoled the CookieManager object, I have got to know that set function is inside default object. So i changed. It works and gives me that success. But when i do getAll, i am getting no result

mallikarjunakp commented 8 years ago

HI, thanks for the reply, I am sorry that i didn't observe the flow. Now i am able to set and get the cookies. but once the app is restart then cookies are gone. Is n't it persistent ?

shexiaoheng commented 8 years ago

you mean callback(res) ?

mallikarjunakp commented 8 years ago

No. What I meant was, I did set the cookie, and then cookies are available throughout the app. But once i close the app and open it again, and try to access the cookies, they are no more. So the persistent problem :(

shexiaoheng commented 8 years ago

After the repair finished bug I'll release a new version

shexiaoheng commented 8 years ago

@mallikarjunakp I made the following changes set(options,callback) -> setCookie(options) getAll(callback) -> getCookie() clearAll(callback) -> removeAllCookies()

iegik commented 7 years ago

v0.2.0

Hello, same problem on Android: When I pass following data to setCookie:

{
domain:"https://example.com/"
expiration:""
name:"auth"
origin:"same origin"
path:"/"
value:"1"
}

I got following from getCookie (parsed):

{auth:"0", ...}

Here is my code: https://gist.github.com/iegik/21633e999aa653b0f046cc31138cdc5b

PS: I write my own mixed class from both react-native-cookies and react-native-cookiemanager

Update:

{
domain:""
expiration:""
name:"auth"
origin:""
path:""
value:"1"
}

Do You check these properties for empty value?

iegik commented 7 years ago

https://gist.github.com/jacobtabak/78e226673d5a6a4c4367