What I want for Christmas

brian_d_foy on 2003-11-26T16:27:00

I want an HTTP cookies server. This server sits on my local machine, and browsers have to request from it existing cookies or give it cookies to store. Every browser can use this, and every browser should.

That way, no matter if I am using Mozilla, iCab, Safari, or Internet Explorer, they all see the same cookies.

Luckily I have already started with the HTTP::Cookies::* modules I have out there. Now I just need to make the server and convince everyone to use it.


Proxy?

samtregar on 2003-11-26T17:59:53

I think you could do it as an HTTP Proxy. Cookies travel in the header so a proxy should be able to capture and add cookies at will.

-sam

Re:Proxy?

brian_d_foy on 2003-11-26T22:44:14

How do the user-agents get access to them? Getting the cookies is not the hard part---finding them later is.

The major problem is that a lot of browsers do it in memory. They read their cookies file, keep it in memory, do stuff, and rewrite it on exit. Once the browser starts up, it has all the cookies it is going to get from anything other than its own requests.

Re:Proxy?

samtregar on 2003-11-26T22:47:43

Web browsers are have builtin HTTP Proxy support. Just open up your preferences and point your browser at the proxy address. Then all your HTTP requests flow through the proxy.

-sam

Re:Proxy?

samtregar on 2003-11-26T22:48:09

... and the proxy can add Cookie: headers at will.

-sam

Re:Proxy?

brian_d_foy on 2003-11-27T12:22:16

I still don't see how this solves the problem of the user agents loading already-set cookies into memory and sharing them with other browsers.

A proxy is solving a different problem than the one I am talking about. :)

Re:Proxy?

samtregar on 2003-11-27T18:05:34

Ok, I don't think I've been very clear. Let me walk you through my crazy scheme.

You write an HTTP proxy that captures cookies and modifies requests to include the cookies from its jar. When a browser makes a request through the proxy the proxy can decide to add cookies to the request based on its own cookie stash. It can ignore the cookies the browser has or doesn't have and substitute its own.

Let's take as an example, me logging in to use.perl in Mozilla, then trying to access the site from IE.

  1. Mozilla logs in to use.perl through the proxy, and supplies no cookies.
  2. The proxy recieves the response and records the cookie, then forwards it to Mozilla.
  3. Later, IE accesses use.perl through the proxy and supplies no cookies.
  4. The proxy notes that it has a valid cookie for use.perl and adds it to the request headers.
  5. IE recieves the cookie on the response and updates its internal store, effectively using the proxy as a cross-browser cookie store.

Does that make things clearer?

-sam

Re:Proxy?

brian_d_foy on 2003-11-28T03:22:48

No, you were clear.

That way the browser knows nothing about it. I want the browser to know about the cookies. I don't want an add on, I want browser support for it.

KeyChain?

Matts on 2003-11-26T21:03:30

You should be able to do this with KeyChain, should you not?

Re:KeyChain?

brian_d_foy on 2003-11-27T12:19:42

You mean the MacOS X thing? I don't know anything about it, but the Help docs only mention passwords and HTML forms auto-fill-in. Additionally, I think the application has to be set up to use it.

Been There, Did That

merlyn on 2003-11-27T01:39:42

You mean you haven't carefully studied all my columns already?

I have a CGI-based remote cookie jar solution, and you could trivially add a persistent cookie jar to my proxy server. Both would work nicely, with differing results.

Re:Been There, Did That

brian_d_foy on 2003-11-27T12:36:38

I still cannot manage stored cookies from the browser.

I do not want a kludgey add-on---I want the browser to participate and to be able to see the cookies. With a proxy I have to develop a lot of external applications to handle all the things I can do in the browser now.

What I want for Christmas is the magical world where all this is built into the user-agents I already use, and it works on every platform,a nd LWP supports it.

And that is pure fantasy. :)

HTTP::Proxy

BooK on 2003-11-27T10:18:02

If you're looking for a proxy that can read and modify anything on both the requests and the response that flow trough it, you can have a look at HTTP::Proxy. It's just a matter of writing the appropriate filters to handle the cookie headers in both the requests and responses.

It's still in development, but I'm using it as my home proxy on a daily basis. So it basically works.

Speaking of cookies, I'll soon publish a very simple script called mergecookies, that reads all your cookie files, merges all the cookies they hold, and stores all those cookies in each file. If a cookie exist in several files, it just keeps the one that expires the later.

Sharing cookies

BooK on 2003-12-02T08:57:50

I know you know how to do this, but...

mergcookies is a little script that will merge all the cookies from all your cookie files. The only requirement is that the correct subclass of HTTP::Cookies is available for each browser. You can share cookies between browsers, though not as instantly as you would like.