CGI question: how do I get the referrer page?

Alan Kennedy alanmk at hotmail.com
Thu May 29 07:06:26 EDT 2003


Will Stuyvesant wrote:

> I want to know the URL where a user comes from.  I read some stuff
> about a HTTP Referer: field (yes, with the typo missing one 'r'). but
> how do I get this information in my CGI script?

import cgi
import os

try:
    referer = os.getenv('HTTP_REFERER')
except KeyError, k:
    referer = None

HTH,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list