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

There is no ability to add additional params to cookies #48

Open
serhiiminin opened this issue May 17, 2018 · 6 comments
Open

There is no ability to add additional params to cookies #48

serhiiminin opened this issue May 17, 2018 · 6 comments

Comments

@serhiiminin
Copy link

How to add expires or path param when we set cookies?

@anubhav7495
Copy link
Contributor

You can use a custom setCookie function to specify expiry for cookies.

import Raven from 'raven';

const paths = { ... };

const setCookie = (name, value, expiry, secure) => {
  // Add your custom implementation for setting cookie
};

const logger = msg => {
  // Log to Sentry
  Raven.captureException(msg);
};

const defaultEqualityCheck = lodash.isEqual;
const defaultDeleteCheck = val => val === null;

const customOptions = {
  logger,
  setCookie,
  defaultEqualityCheck,
  defaultDeleteCheck,
};

reduxCookiesMiddleware(paths, customOptions);

@anubhav7495
Copy link
Contributor

At this moment you cannot set a custom path for cookies. Do you wish to open a PR for it? Contributions welcome.

@buddyp450
Copy link

I honestly feel like the current ability to pass in your own setCookie implementation is fine. Ran across this issue and it took 2 minutes to implement. Given that the underlying cookie interface can be different from implementation to implementation (i.e. js-cookie expects days where-as some other api may expect ms) I feel like keeping this the way it is would be safer.

@LonguCodes
Copy link

Okey, but how do we specify if we want a secure cookie? Or when should it expire?

@lucasjmatias
Copy link

lucasjmatias commented Apr 14, 2020

I wish I could set expiry in a simpler way, like this:

const paths = {
    'mydata': { name: 'cookie_name', expiry: 1 },
    'mydata2': { name: 'cookie_name_2', expiry: 15 },
}

I really don't want to implement my own setCookie since all I wanted is to change only the expire time and it'd be cool to be able to set different expiry times for different cookies.

May I implement this or this library is not suppose to work this way?

@AndersRemienHansen
Copy link

@lucasjmatias felt exactly the same. Especially that changing expiry shouldnt warrant providing as new setCookies implementation. Did you do anything regarding this?

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

No branches or pull requests

6 participants