tags:

views:

71

answers:

2

I'm creating a website with a database search functionality, but I want to make the user login or create a account first to use the search functionality. How do I do this? And what is the easiest way to carry the login session forward. I.E. the user only has to login once to do many searches.

+1  A: 

Look at Web Frameworks for Python, and select one of the listed Popular Full-Stack Frameworks (Django, TurboGears, ...). Each framework provides its own session support.

SO discussions, for example choosing-a-web-application-framework-in-python, can help you choose one that meets your requirements.

gimel
A: 

If you're using Apache as your web server you can use the built-in Htaccess command line tools for user management: http://en.wikipedia.org/wiki/Htaccess

Htaccess is built-in to Apache and lets you manage users for PHP pages, CGI's (including Python), HTML pages, and others.

Here's a few example use-cases:

  1. Initial setup:

    a. copy 3 .ht* files (.htpasswords, .htgroups, .htaccess) into your document root (find templates of these files on the web).

    b. add "AllowOverride Authconfig" into your apache conf file

  2. Create new user ('root') when .htpasswords file does not exist:

    $ htpasswd -c .htpasswords root

  3. add a user named 'root':

    $ htpasswd /Users/username/Sites/.htpasswords root

  4. change password of user 'root':

    $ htpasswd /Users/username/Sites/.htpasswords root

In PHP you can see who logged in via htaccess and get their password with:

$pass = $_SERVER['PHP_AUTH_PW']; // from htaccess

Htaccess is not super user-friendly, so feel free to update/improve my workflow

russian_spy