473,545 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Persistent Session in CGI

Hi,

I have started a new small web project, and was wondering if there are
any good guides on how to do Persistent Sessions and Authentication
using python and CGI. I don't really want too use Zope, because It's
probably overkill for my tiny project.

Aug 27 '06 #1
4 2918
ke***********@g mail.com writes:
I have started a new small web project, and was wondering if there are
any good guides on how to do Persistent Sessions and Authentication
using python and CGI. I don't really want too use Zope, because It's
probably overkill for my tiny project.
The simplest thing to do is put all the session info into a browser
cookie. That limits the amount of session info but maybe you can live
with that. You should encrypt and authenticate the cookie to prevent
the user from tampering with it.
Aug 27 '06 #2

ke***********@g mail.com wrote:
Hi,

I have started a new small web project, and was wondering if there are
any good guides on how to do Persistent Sessions and Authentication
using python and CGI. I don't really want too use Zope, because It's
probably overkill for my tiny project.
You could try my 'logintools' CGI module (mini framework really, but
very mini).

It handles authentication for you, and provides a mechanism that you
could use to create persistent sessions.

http://www.voidspace.org.uk/python/logintools.html

(It uses cookies).

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Aug 27 '06 #3
I have started a new small web project, and was wondering if there are
any good guides on how to do Persistent Sessions and Authentication
using python and CGI. I don't really want too use Zope, because It's
probably overkill for my tiny project.
Since you only mention Zope...
Why not use TurboGears or Pylons or CleverHarold ... or anything WSGI based.
Or if you want to make something minimal you could try Paste with
(optionally) RhubarbTart.

But.. WSGI is the new CGI (the lowest common denominator) in Python web
development. So use it.
The benefits:
You can run your app as CGI, in mod_python, as a standalone http server,
with SCGI/FastCGI.
You'll benefit from authentication and session middleware. Middleware is a
great WSGI concept, there are also caching middlewares etc..

--
damjan
Aug 31 '06 #4
But.. WSGI is the new CGI

Let me give you a minimal example using RhubarbTart (it depends on Paste)

from rhubarbtart import request, response, expose
from rhubarbtart import TartRootControl ler

class Root(TartRootCo ntroller):
@expose
def index(self, msg="Hello world!"):
response.header s['Content-type'] = 'text/plain'
return msg

app = Root()

#
# Now to serve it as a CGI script, just:
#
from wsgiref.handler s import CGIHandler
CGIHandler().ru n(app)

#
# or to server it in a long running python-based HTTP server
#
from paste import httpserver
httpserver.serv e(app)

# END of example

Now this is just the begining to show you that it's not hard.
But when you see what EvalException can do for you, you'll beg for more :)

Hint:
from paste.evalexcep tion.middleware import EvalException
app = EvalException(a pp)
# then serve the app in the paste httpserver ...
# but make some error in your python code to see it's results
--
damjan
Aug 31 '06 #5

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

Similar topics

4
4388
by: M. Katz | last post by:
I'm relatively new to PHP/MySQL and I've heard about maintaining a persistent connection to the database. To save overhead, I'd like to maintain the connection in a session variable, but I have a few questions first. I'm able to establish session variables and test them with isset() to avoid re-defining them with each new web-page load. So...
5
2789
by: Felix E. Klee | last post by:
I've set up a PHP web application where users can log in and open a connection to a NNTP-server. There is a *one-to-one* relationship between sessions and NNTP-connections (i.e. exactly one NNTP-connection per session, and exactly one session per NNTP-connection). Now, I'd like to have these connections be persistent. So I started using...
0
2479
by: obhayes | last post by:
Hi All, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the webserver (therefore do not intend to use the session object- as you cannot gaurantee which server the user will go to). I want to store a small value...
1
4596
by: brad | last post by:
Hi, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the webserver (therefore do not intend to use the session object- as you cannot gaurantee which server the user will go to). I want to store a small value...
0
1855
by: Kepler | last post by:
I'm testing very basic FormsAuthentication and having trouble with non-persistent cookies. Once authenticated with a non-persistent cookie, if I leave the browser alone for 30 minutes, Request.IsAuthenticated returns false on my next request. WHY? At first I thought it had to do with session timeout, but session timeout is set to 20...
5
1511
by: Max | last post by:
Hi All! I'm doing an ASP.NET project which uses Persistent Forms Authentication (i.e. once user logged in, they don't have to log in again). However Session variables are erased after Session has timed out. So I need to re-populate user specific session variables (such as user email, DOB, Full Name...etc) when Session has ended. But...
8
3175
by: bashful.belle | last post by:
I'm using Forms authentication and a non persistent cookie in my asp.net application. How do i get the cookie to time out after a period of inactivity, say 10 minutes, and force the user to login again? If I close the browser, the next time I use the application, it makes me log in - and That's fine. However if I keep the browser session...
3
2114
by: Arnost Sobota | last post by:
Dear ASP community, I have a question regarding ASP session variables. My assumption was that a session variable has the same lifetime as the session itself: as a consequence, given that closing the browser doesn't terminate the session, the session variable is kept alive until the session expires. But, surprisingly, I've found this to...
3
4287
by: sanchita | last post by:
Hello everyone, I didn't get any response in "Security" forum hence posting here again. I am having problem with persistent cookies. Even after setting "CreatePersistentCookie" to true in "FormsAuthentication.SetAuthCookie" I'm being logged out after the specifed timeout provided in "forms" element of web.config. I read somewhere that...
5
2754
by: lawpoop | last post by:
Hello all! I'm working on a PHP site using Postgres as a back-end. I have an include at the top of each page that runs the pg_connect function. I'm implementing some temporary tables, which I understand are destroyed automatically at the end of the session. It seems to me that when I navigate to a new page, or re-load my existing page, I...
0
7484
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...
0
7928
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...
1
7440
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...
0
7775
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...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4963
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...
0
3470
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...
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.