Code Monkey home page Code Monkey logo

Comments (3)

falconegabriel avatar falconegabriel commented on August 18, 2024 1

I may be mistaken, but as I was reading the code for the class

public class SharedPrefsCookiePersistor implements CookiePersistor {
    [ ... ]
    @Override
    public void saveAll(Collection<Cookie> cookies) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        for (Cookie cookie : cookies) {
            if (cookie.persistent()) {
                editor.putString(createCookieKey(cookie), new SerializableCookie().encode(cookie));
            }
        }
        editor.apply();
    }
   [ ... ]
}

The following piece of code seems weird:

if (cookie.persistent()) {
     editor.putString(createCookieKey(cookie), new SerializableCookie().encode(cookie));
}

As shown here

public boolean persistent()
Returns true if this cookie expires at the end of the current session.

The method 'Cookie.persistent()' returns true when it expires at the end of the current session... So shouldn't it be stored when this flag returns false?

I may be mistaken, but I think the issue is the misleading method which seems to do the opposite as you would expect.

from persistentcookiejar.

franmontiel avatar franmontiel commented on August 18, 2024

For now I haven't been able to reproduce any problems with the expiry dates. Also I think that there is an error in the OkHttp Javadoc:

Check this line comment.

private final boolean persistent; // True if 'expires' or 'max-age' is present.

Looking at how the variable is assigned when parsing the cookie seems that the behavior of the persistent flag is the opposite to the one indicated in the javadoc.

from persistentcookiejar.

lejun avatar lejun commented on August 18, 2024

Thank you for your reply! !

I rewrote saveAll method, do not check the persistent.(The problem may be the server.) Operating normally.

Thanks!!

from persistentcookiejar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.