I'm writing a web service which stores data which will be shared between two separate systems.
/session/requestNewSession?args=<data> => returns session id
/session/requestArgs?session=<session id> => returns <data> stored with key <session id>
The code is implemented in python in the twisted matrix library, and I've written my own session id generator:
private_secret = os.urandom(64)
def generateRandomSessionKey():
 rawdata = private_secret + str(time.time()) + string.join(map(chr, [random.randint(0,255) for x in range(100)]),"")
 session_key = hashlib.sha256(rawdata).hexdigest()
 del(rawdata)
 return session_key
Is this a proper way of generating a secure session id (unguessable)? If not, any ideas on what I should do differently?