title: Simple python CGI cookie script, get's data from form
body: <p>Hello all I am trying to create a very simple python CGI script that takes form data and puts it in a COOKIE. Here is my code.</p>
  
  <pre><code>#!/usr/bin/python
  print "Content-type: text/html"
  print 
  
  import Cookie, cgi, os, cgitb, smtplib, sys
  cgitb.enable()
  
  form = cgi.FieldStorage()
  
  ID = form.getvalue('ID')
  name = form.getvalue('name')
  telephone = form.getvalue('telephone')
  email = form.getvalue('email')
  manager = form.getvalue('manager')
  
  
  
  def set_clientCookie(ID, name, telephone, email, manager):
   #create object
   myCookie = Cookie.SmartCookie()
  
   #Assign value
   myCookie['ID'] = ID
   myCookie['Name'] = name
   myCookie['Tele'] = telephone
   myCookie['Email'] = email
   myCookie['Manager'] = manager
  
   #Send back to client
   print "Content-type: text/html"
   print
   print myCookie, "\n\n"
  
  set_clientCookie(ID, name, telephone, email, manager)
  </code></pre>
  
  <p>As you can see it is very basic, but I am receiving a "Premature end of script headers error in the logs. </p>