Skip to content

Remove yiisoft/cookies dependency #134

Open

Description

@vjik

The package uses only a tiny part of yiisoft/cookies — building a single Set-Cookie header in CookieLogin. It would be nice to drop it.

Activity

  1. klsoft-web commented on Sep 3, 2026

    @klsoft-web
    Contributor

    Getting rid of the unnecessary dependencies is a good idea. I think we can remove yiisoft/cookies, along with CookieLogin, CookieLoginIdentityInterface and CookieLoginMiddleware, and put them in a separate package called yiisoft/cookie-login.
    The new package, yiisoft/cookie-login, will depend on the yiisoft/user and yiisoft/cookies packages.
    This will reduce the dependencies for the yiisoft/user package.

  2. vjik commented on Sep 3, 2026

    @vjik
    MemberAuthor

    Getting rid of the unnecessary dependencies is a good idea. I think we can remove yiisoft/cookies, along with CookieLogin, CookieLoginIdentityInterface and CookieLoginMiddleware, and put them in a separate package called yiisoft/cookie-login.
    The new package, yiisoft/cookie-login, will depend on the yiisoft/user and yiisoft/cookies packages.
    This will reduce the dependencies for the yiisoft/user package.

    We can leave CookieLogin, CookieLoginIdentityInterface and CookieLoginMiddleware in yiisoft/user, just implement it without yiisoft/cookies usage.

  3. klsoft-web commented on Sep 3, 2026

    @klsoft-web
    Contributor

    If we implement these classes without using the yiisoft/cookies package, we will end up writing new code to achieve the same result, rather than making use of existing code within the package.
    The yiisoft/session package also uses "a tiny part" of the yiisoft/cookies package. If so, should we remove the yiisoft/cookies package from the yiisoft/session package too?

  4. vjik commented on Sep 3, 2026

    @vjik
    MemberAuthor

    If so, should we remove the yiisoft/cookies package from the yiisoft/session package too?

    No. We use contract SessionInterface, therefore, I would keep the yiisoft/session dependency.

  5. klsoft-web commented on Sep 3, 2026

    @klsoft-web
    Contributor

    The package uses only a tiny part of yiisoft/cookies — building a single Set-Cookie header in CookieLogin. It would be nice to drop it.

    I used the yiisoft/session package as an example of one that also uses "a tiny part" of the yiisoft/cookies package.
    What criterion should we use to decide whether a part is "tiny" enough to justify removing the yiisoft/cookies package?

  6. samdark commented on Sep 4, 2026

    @samdark
    Member

    That is a very good question. It is a balance.

    For dependency, it is all about code reuse:

    1. Code amount is significant.
    2. Code itself is non-trivial.
    3. It should be kept in sync.

    Against dependency:

    1. Only a fraction of the code from the package is used.
    2. The used code is very simple.
    3. It would not require any maintenance.
    4. It doesn't have to be kept in sync with anything.
  7. klsoft-web commented on Sep 4, 2026

    @klsoft-web
    Contributor

    These arguments are valid.
    However, even if the yiisoft/cookies dependency were removed from yiisoft/user, an app using the yiisoft/user package would still have the yiisoft/cookies dependency, as yiisoft/user depends on yiisoft/session, which depends on yiisoft/cookies.
    So what would be the point of removing the yiisoft/cookies dependency from yiisoft/user?

  8. samdark commented on Sep 4, 2026

    @samdark
    Member

    Yes, if there is such a cyclic dependency, then that's a no-go, it makes no sense.

  9. samdark commented on Sep 4, 2026

    @samdark
    Member
  10. vjik commented on Sep 6, 2026

    @vjik
    MemberAuthor

    Yes, if there is such a cyclic dependency, then that's a no-go, it makes no sense.

    It can be fixed: yiisoft/session#86 . In sessions yiisoft/cookies dependency need even less.

  11. klsoft-web commented on Sep 6, 2026

    @klsoft-web
    Contributor

    In my opinion, it would make sense to remove the yiisoft/cookies dependency from yiisoft/session, as this would not affect the other code.
    However, it would be unwise to remove the yiisoft/cookies dependency from yiisoft/user, since having two incompatible cookie protection methods within the same framework would cause problems.

  12. vjik commented on Sep 6, 2026

    @vjik
    MemberAuthor

    two incompatible cookie protection methods within the same framework would cause problem

    Why "incompatible"? This is compatible, even if the user uses both the middleware from yiisoft/cookies and the built‑in protection by yiisoft/user, everything will work. Right?

  13. klsoft-web commented on Sep 7, 2026

    @klsoft-web
    Contributor

    Why "incompatible"? This is compatible, even if the user uses both the middleware from yiisoft/cookies and the built‑in protection by yiisoft/user, everything will work. Right?

    It's because CookieSigner uses the MD5 value for signing, unlike CookieLogin.

  14. vjik commented on Sep 7, 2026

    @vjik
    MemberAuthor

    It's because CookieSigner uses the MD5 value for signing, unlike CookieLogin.

    This is an independent functionality. CookieSigner and CookieLogin doesn't affect each other.

  15. klsoft-web commented on Sep 7, 2026

    @klsoft-web
    Contributor

    This is an independent functionality. CookieSigner and CookieLogin doesn't affect each other.

    Yes, they don't affect each other directly, but rather via cookies. For example, you could use CookieLogin for a signed cookie, and then use Yiisoft\Cookies\CookieMiddleware plus MyCookieLoginMiddleware instead of CookieLoginMiddleware for an unsigned one.

  16. vjik commented on Sep 7, 2026

    @vjik
    MemberAuthor

    This is an independent functionality. CookieSigner and CookieLogin doesn't affect each other.

    Yes, they don't affect each other directly, but rather via cookies. For example, you could use CookieLogin for a signed cookie, and then use Yiisoft\Cookies\CookieMiddleware plus MyCookieLoginMiddleware instead of CookieLoginMiddleware for an unsigned one.

    If you use CookieLogin into MyCookieLoginMiddleware, it will be work.

  17. klsoft-web commented on Sep 7, 2026

    @klsoft-web
    Contributor

    If you use CookieLogin into MyCookieLoginMiddleware, it will be work.

    In the above example, I suppose that Yiisoft\Cookies\CookieMiddleware is responsible for unsigned cookies, which is why I mentioned incompatible cookie protection methods within the same framework.

  18. vjik commented on Sep 7, 2026

    @vjik
    MemberAuthor

    In the above example, I suppose that Yiisoft\Cookies\CookieMiddleware is responsible for unsigned cookies, which is why I mentioned incompatible cookie protection methods within the same framework.

    There should be no situation where CookieLogin encodes a cookie value and then it is not used for decoding. The presence of CookieMiddleware does not affect this.

    request - CookieMiddleware (encode/decode) - CookieLogin — CookieMiddleware here always make own work before CookieLogin.

  19. klsoft-web commented on Sep 7, 2026

    @klsoft-web
    Contributor

    Are you planning to add the ability to encrypt cookie values, thus making the yiisoft/user package equivalent to the yiisoft/cookies dependencies that were removed in terms of cookie protection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions