473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

PHP session equivalent?


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
Jul 18 '05 #1
3 3559
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.

Jul 18 '05 #2
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
Jul 18 '05 #3
"Erik Johnson" <sp**@nospam.org> 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 jm*****@carcosa.net |
| "If you wish to make Pythocles wealthy, don't give him more |
| money; rather, reduce his desires." -- Epicurus |
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
3
by: Jerry Sievers | last post by:
Hello. I have session files stored in a special tmp directory specific to a virtual host instance. The Max_lifetime is long 86400 (1 day) which I don't suppose is the problem. Anyway the...
14
by: dale zhang | last post by:
Hi groups, Can anyone give me the equivalent C# sharp code for this VB.ET code, :: VB.NET :: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles...
8
by: Anthony P. Mancini | last post by:
I'm working on a proof of concept that will ultimately be deployed on a load balancer. For the sake of a preliminary demonstration I created a C# object and marked it's attributes as Public...
2
by: tshad | last post by:
I was looking at different ways of doing the same thing and at the moment was looking at the use of "is" and "=", as I have at times found that I will do something like if something = 0 and...
1
by: Tarren | last post by:
Hi: In Visual Basic is there the equivalent of a Session variable where I can store variables in memory while the executable is running? I have been coding ASP .NET for some time, but am new to...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
1
by: KidQuin | last post by:
I am having problems with session value between pages. Happening in both firefox and IE7. I go between page by links so I know it's not header changes. I use session_start as the first line on the...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.