On Tue, Mar 11, 2014 at 6:06 PM, Klaus Trainer <notifications@github.com>wrote:

> In src/couch_replicator/src/couch_replicator_httpc.erl:
>
> > +    true -> start_new_session(HttpDb, Worker)
> > +    end.
> > +
> > +
> > +need_new_session(#httpdb{credentials = undefined}) ->
> > +    false;
> > +
> > +need_new_session(#httpdb{credentials = Credentials}) ->
> > +    case ets:lookup(Credentials, cookie) of
> > +    [] ->
> > +        true;
> > +    [{cookie, _, UpdatedAt}] ->
> > +        %% As we don't know when the cookie will expire, we just decide
> > +        %% that we want a new session if the current one is older than
> > +        %% one minute.
> > +        OneMinute = 60 * 1000000, % microseconds
>
>  Well when you get the expires times in the cookie and compare it to
>
> the current hour on your machine you know the delay in which the
> cookie is supposed to expire.
>
>  Being able to do that would be nice, but the problem is that currently
> there is no expiry time in the cookie. The timestamp contained in the
> cookie is generated by make_cookie_time/0, which is the time in
> seconds at the point in time when the cookie was created, and therefore
> not really helpful. We can currently only make guesses about how long
> a cookie is be valid.
>

If the expires time is not present, then why not adding it? But If I read
wel the code of `mochiweb_cookies:cookie/3` [1] you get the expires time
from the cookie header:

https://github.com/mochi/mochiweb/blob/master/src/mochiweb_cookies.erl#L63

and then it should be possible to do the above. Once I have access to a
machine i will do the test.


> --
> Reply to this email directly or view it on GitHub<https://github.com/apache/couchdb/pull/172/files#r10483984>
> .
>