def generate_cookie(k, v, max_age=None, domain=None, path=None, comment=None, secure=False):
 retval = deque([('%s=%s' % (k, v))])
 if (max_age is not None):
  retval.append(('Max-Age=%d' % max_age))
  assert (time.time() < sys.maxint)
  expires = (time.time() + max_age)
  expires = (min((2 << 30), expires) - 1)
  retval.append(('Expires=%s' % strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(expires))))
 if (domain is not None):
  retval.append(('Domain=%s' % domain))
 if (path is not None):
  retval.append(('Path=%s' % path))
 if (comment is not None):
  retval.append(('Comment=%s' % comment))
 if secure:
  retval.append('Secure')
 return '; '.join(retval)

def generate_cookie ( k , v , max_age = None , domain = None , path = None , comment = None , secure = False ) : retval = deque ( [ ( '%s=%s' % ( k , v ) ) ] ) if ( max_age is not None ) : retval . append ( ( 'Max-Age=%d' % max_age ) ) assert ( time . time ( ) < sys . maxint ) expires = ( time . time ( ) + max_age ) expires = ( min ( ( 2 << 30 ) , expires ) - 1 ) retval . append ( ( 'Expires=%s' % strftime ( '%a, %d %b %Y %H:%M:%S GMT' , gmtime ( expires ) ) ) ) if ( domain is not None ) : retval . append ( ( 'Domain=%s' % domain ) ) if ( path is not None ) : retval . append ( ( 'Path=%s' % path ) ) if ( comment is not None ) : retval . append ( ( 'Comment=%s' % comment ) ) if secure : retval . append ( 'Secure' ) return '; ' . join ( retval )
generates random transaction cookie .