Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cookies are not persistent #2

Open
mallikarjunakp opened this issue Aug 19, 2016 · 9 comments
Open

cookies are not persistent #2

mallikarjunakp opened this issue Aug 19, 2016 · 9 comments

Comments

@mallikarjunakp
Copy link

mallikarjunakp commented Aug 19, 2016

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
Copy link
Contributor

try change there

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

to

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

@mallikarjunakp
Copy link
Author

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
Copy link
Author

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 ?

@mallikarjunakp mallikarjunakp changed the title setCookie URL problem cookies are not persistent Aug 19, 2016
@shexiaoheng
Copy link
Contributor

you mean callback(res) ?

@mallikarjunakp
Copy link
Author

mallikarjunakp commented Aug 19, 2016

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
Copy link
Contributor

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

@shexiaoheng
Copy link
Contributor

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

@iegik
Copy link
Contributor

iegik commented May 4, 2017

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"
}
  • same result

Do You check these properties for empty value?

@iegik
Copy link
Contributor

iegik commented May 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants