PHP session equivalent?

Discussion in 'Python' started by Erik Johnson, Feb 12, 2005.

  1. Erik Johnson

    Erik Johnson Guest

    There are a lot of things about PHP I was not too keen on and hence why
    my company is primarily doing Python these days, but one thing I was quite
    impressed with was the ease with which it provided session functionality...

    <?php

    session_start();
    session_register['my_var'];

    $my_var = "whatever";

    ?>

    And then in another CGI script do basically the same thing and get the
    value of $my_var back. Setting of a session ID cookie happens automagically.
    This is quite handy and simple.

    I don't think it's quite so simple in Python (which is not to say I
    think PHP is better than Python). Doing a little extra work is no big deal,
    but could someone be so kind as to lay out what needs to be done for a
    Python CGI script to get essentially the same functionality? Are there
    Python modules that implement a lot of this already?

    We are currently running under an Apache server (on SuSE Linux 8.2). I'm
    not clear on whether some session functionality is provided there? We may be
    moving to Zope before too long (trying to find some time to evaluate it), so
    a method that is not strictly dependent on Apache would be preferable (in
    the short term that may suffice).

    Thanks for taking the time to read my post! :)

    -ej
     
    Erik Johnson, Feb 12, 2005
    #1
    1. Advertising

  2. Erik Johnson wrote:

    > There are a lot of things about PHP I was not too keen on and hence
    > why
    > my company is primarily doing Python these days, but one thing I was quite
    > impressed with was the ease with which it provided session
    > functionality...


    Like you I think it is a big plus of PHP as a beginner's web development
    tool that it provides session management out of the box. It would certainly
    make python more attractive for beginners if they could use session
    management out of the box, too. (I know that there are lots of web
    development frameworks, but they are to be too difficult to learn, if you
    are new to web development).

    There is no module for session management in the python standard library.
    But there are lots of python frameworks that would do this job well (my
    favorite: cherrypy). If you think that a whole framework would be overkill,
    you either could try to recylce the session part of an existing framework,
    or you could write a module for yourself.

    I have written a module which is quite similar to the php session
    management, except for that it does no url rewriting when cookies are not
    allowed. If you are interested, I will mail you a copy.
     
    Walter Burleigh, Feb 12, 2005
    #2
    1. Advertising

  3. Walter Burleigh wrote:
    > Erik Johnson wrote:
    >
    >> There are a lot of things about PHP I was not too keen on and hence
    >> why
    >> my company is primarily doing Python these days, but one thing I was quite
    >> impressed with was the ease with which it provided session
    >> functionality...

    >
    > Like you I think it is a big plus of PHP as a beginner's web development
    > tool that it provides session management out of the box. It would certainly
    > make python more attractive for beginners if they could use session
    > management out of the box, too. (I know that there are lots of web
    > development frameworks, but they are to be too difficult to learn, if you
    > are new to web development).
    >
    > There is no module for session management in the python standard library.
    > But there are lots of python frameworks that would do this job well (my
    > favorite: cherrypy). If you think that a whole framework would be overkill,
    > you either could try to recylce the session part of an existing framework,
    > or you could write a module for yourself.
    >
    > I have written a module which is quite similar to the php session
    > management, except for that it does no url rewriting when cookies are not
    > allowed. If you are interested, I will mail you a copy.


    If you need session management, and do not want a complicated web app
    framework, check out pso: http://pso.sf.net

    Reinhold
     
    Reinhold Birkenfeld, Feb 12, 2005
    #3
  4. "Erik Johnson" <> writes:

    > I don't think it's quite so simple in Python (which is not to say I
    > think PHP is better than Python). Doing a little extra work is no big deal,
    > but could someone be so kind as to lay out what needs to be done for a
    > Python CGI script to get essentially the same functionality? Are there
    > Python modules that implement a lot of this already?


    Take a look at jonpy (jonpy.sourceforge.net). jon.session does pretty
    much exactly what you want. There are lots of other python web
    frameworks that also provide this, but jonpy is one of the smallest
    and conceptually simplest.

    --
    +----------------------------------------------------------------+
    | Jason F. McBrayer |
    | "If you wish to make Pythocles wealthy, don't give him more |
    | money; rather, reduce his desires." -- Epicurus |
     
    Jason F. McBrayer, Feb 13, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    2
    Views:
    1,133
  2. Olivier Noblanc ATOUSOFT

    find isset() php function equivalent in python

    Olivier Noblanc ATOUSOFT, Feb 1, 2005, in forum: Python
    Replies:
    3
    Views:
    901
    Ola Natvig
    Feb 1, 2005
  3. Maksim Kasimov

    python equivalent of php implode

    Maksim Kasimov, Apr 26, 2005, in forum: Python
    Replies:
    11
    Views:
    3,979
    Dave Cook
    Apr 28, 2005
  4. praba kar
    Replies:
    0
    Views:
    292
    praba kar
    May 12, 2005
  5. Rajive Narain
    Replies:
    0
    Views:
    2,072
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page