title: How to clear cookies using python 2.6.x cookielib
body: <p>It seems my previous description was not clear, so rewriting it. </p>
  
  <p>Using python urllib2, I am automating fileupload task in my webapp. And am using Cookielib to store session information, and also I could able to successfully automate the fileupload task. Problem is, when I change the login credentials and did not supply those or supply wrong login credentials to automated python script, it still processing fileupload successfully. In this case, it should actually fail.</p>
  
  <p>All I want is, how to clear the cookielib generated cookies.</p>
  
  <p>Below is the code snippet....</p>
  
  <pre><code>cookies = cookielib.CookieJar()
  cookies.clear_session_cookies()
  #cookies.clear() tried this as well
  opener = urllib2.build_opener(SmartRedirectHandler,HTTPCookieProcessor(cookies),MultipartPostHandler)
  
  urllib2.install_opener(opener)
  login_req = urllib2.Request(login_url, login_params)
  res = urllib2.urlopen(login_req)
  #after login, do fileupload
  fileupload_req = urllib2.Request(fileupload_url, params)
  response = urllib2.urlopen(import_req) 
  </code></pre>
  
  <p>I tried using clear() and clear_session_cookies() but still cookies are not cleared. </p>