Welcome, guest | Sign In | My Account | Store | Cart


Name:        newSID.py
Author:      Bill Anderson <bill@noreboots.com>
License:     LGPL

This is a nice little means of generating a 
"Session ID" for things like web sessions and the like.

It returns an ID of the format:

where "Joe" was the string passed to the function.

import time,whrandom,md5

def getNewSID(tag):
	"""Build a new Session ID"""
	t1 = time.time()
	time.sleep( whrandom.random() )
	t2 = time.time()
	base = md5.new( tag + str(t1 +t2) )
	sid = tag + '_' + base.hexdigest()
	return sid

if __name__ == '__main__':
	print getNewSID('Joe')