Select fails when cookie tried to get a numeric value

Denis McMahon denismfmcmahon at gmail.com
Sun Oct 6 10:57:46 EDT 2013


On Sun, 06 Oct 2013 08:20:35 +0300, Νίκος Αλεξόπουλος wrote:

> Thank you Denis, i didn't knew about sessions up until i saw you post.
> Your code is very advanced for me to read but i will try to "decode it"
> I though that if we want to read something from our visitor, something
> we want, we have to save it to his browser a cookie, that we later
> retrieve within our python script's code.
> 
> What "sessions" do more compared to just using cookies?

The concept of a session is that you preserve data in the server between 
multiple page requests from the same client.

You do this by issuing a session id to the client in a cookie, and using 
the session id as a key to identify that user's data in the server.

I use the session id as a filename in the tmp files dir on the server, 
and in the file I store a pickled dictionary that contains all the 
session data for the user. It should be just as easy to do this using a 
database with three fields, the session id, the last used time, and a 
binary object (or a string) to hold the pickled data. You could use json 
instead of pickle, that just creates a string.

The big advantage of a session is that you keep the data on the server, 
and only send the session id to the browser. This means that the user can 
not manipulate the session data.

If you don't understand why this is important, you need to stop coding 
websites until you do understand why this is important. As the importance 
of this is not a python issue, it is not appropriate to discuss here.

> i use 'cgi', but i noticed you used 'mod-wsgi'.
> I want to ask you why you chose the latter? Is the latter better than
> the former?

It was a choice between mod-python and mod-wsgi. I chose mod-wsgi. I 
think I felt that it was better supported in apache than mod-python, and 
it seemed to be better thought of in various forums.

> Is it faster? Does it bahave the same way?

I have no idea. I prefer using specific apache modules for server side 
scripting where possible, rather than cgi, as I find that they are 
generally less cpu and memory intensive than using the cgi interface.

Although my compiled fortran, ada, basic, pascal and c modules still use 
mod-cgi.[1]

> I my code works works with cgi, which it does, will the same code works
> with mod-wcgi?

I have no idea. Also, what is mod-wcgi anyway?

[1] I got bored one weekend and decided to write basic form handling in 
several of the languages I knew just to prove I could do it.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list