Cookies

Ken Seehof kens at sightreader.com
Fri Mar 16 12:18:25 EST 2001


Yeah, that's the closest I've come up with too, but the difficulty is making
the system reliably support all browsers.  Unfortunately from the point of
view of a standalone application, there is no standard for cookies.  Cookies
are standardized from the point of view of servers and javascript, but that
doesn't help me with a standalone app.

The best approach so far seems to be to have the server send back a page
with a 10 digit unique identifier in a large font.  The python app would
then ask the user to type in the number manually.  Seems kinda dumb that I
need the users fingers as part of my protocol. :-)

- Ken

----- Original Message -----
From: "Greg Jorgensen" <gregj at pobox.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, March 15, 2001 11:35 PM
Subject: Re: Cookies


> A cookie is just a text file stored in a special place where the browser
can
> find it. Where exactly the cookies go depends on your OS and browser.
>
> Using a text file to store the key would seem the easiest solution, but
> client-side Javascript can't create or write a file.
>
> I think you should generate unique IDs on the server, not on the client.
> Here's one way to handle it:
>
> 1. Client browser sends form data to server.
> 2. Server processes form, generates a unique ID, stores the form data
keyed
> by the unique ID.
> 3. Server replies with a "thank you" or "database updated" page that also
> writes a cookie.
> 4. Python program starts up and looks for the cookie. Depending on your OS
> and browser the location and name of the cookie will vary, but with a
little
> experimenting you can easily find the most likely locations.
> 5. Python program reads the cookie. Open your cookie with a text editor to
> see what's in there--it's just name: value pairs.
> 6. Python program sends HTTP request to server with unique ID it got from
> the cookie.
>
> Obviously this won't work if the client has disabled cookies. With a
little
> more trouble you can detect this and perhaps put the unique ID on the
> response page and tell the user to save it or something. Or embed the
unique
> ID in the reply page and tell the user to save that page and give it a
> specific name, then have your Python program open that text file and find
> the unique ID in there.
>
> Depending on your requirements and security concerns, you can either have
> your database program generate the unique ID (my preference), use the
> Windows GUID functions (which are available to ASP on the server), or
> implement one of the GUID functions you can easily find on the web. Many
> programmers have solved this in one way or another; send email to me if
you
> want specific advice on generating unique IDs from your database engine.
>
> Good luck.
>
> <<<
> "Ken Seehof" <kens at sightreader.com> wrote in message
> news:mailman.984707839.22839.python-list at python.org...
> Short version:
>
> Is it possible for a stand-alone python application to read a cookie
without
> the help of a browser?"
>
> Long version:
>
> I have a web page W and a client side python script P.  I want W to
generate
> a GUID (perhaps using javascript) which is then sent to a server S, where
it
> is to be used as a key in a database.  Now I run P (on the client, and not
> in a browser) and I want P to somehow find the value of the GUID, so that
it
> can query the database on S.
>
> Alternate question:
>
> Is there a technique common to both javascript and python that will obtain
a
> unique identifier for a computer (e.g. IP address).  It must not be
browser
> specific.
>
> Motivation:
>
> I need to write a record of data from an html form, keyed by some kind of
> unique client id, to the server and then be able to query that record from
a
> stand alone python script running on the client.  The missing link is
> getting the html form and the python script to agree on a value for the
id;
> the rest is easy.
> >>>
>
> --
> Greg Jorgensen
> PDXperts
> Portland, Oregon, USA
> gregj at pobox.com
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list