473,735 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_registe r['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 3589
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.or g> 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.sourcefo rge.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
3309
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 and a couple "better pratice" code. Not perfect, but better. Problem : I'm testing everything with Firefox on my machine (IIS on WinXP Pro), and everything is ok. As soon as I try MS IE 6, it doesn't seem to keep the sessions from page to...
3
1701
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 sessions do indeed expire and "most" of the old session files disappear as expected. Not all however. I am finding several old session files with Unix
14
5918
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 MyBase.Load 'This event routine in the loginCheck user control fires when the
8
1727
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 Shared Static. I also set the EnableSessions and EnableViewState Page directives to false. Here's the part that stumped me : as I was moving from page to page within the demo, I accidently realized the data I dropped
2
1173
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 will get an error that says I can't use "=" (or <>) in this case case I must use "is" ( or not something is). I am trying to find out when this is the case - when I can use the "=" and when I have to use "is.
1
534
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 Windows forms. TIA - Tarren
0
3236
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 documentation it seems it should do it anyway any advice?
14
2380
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 User B has access to 5, now when both of us hits to the server at the same time then their session variables gets mixedup means either User A and USer B will have now 5 companies or both have 10 companies. Now again when User A hits to the server...
1
8979
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 page creating the session and the new page. The problem just start when code was untouched. I am using PHP 4.4.7 on an Apache Server. Any help or suggestions would be welcomed here is my php.ini file ; Handler used to store/retrieve...
0
8965
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9466
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3278
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.