-
- # Get the next session hash available, and increment the session id cache
- fun next_session_hash: String
- do
- var id = next_session_id_cache
- # On firt evocation, seed the pseudo random number generator
- if id == null then
- srand
- id = 1000000.rand
- end
-
- next_session_id_cache = id + 1
-
- return id.to_id_hash
- end
-
- private var next_session_id_cache: nullable Int = null
-
- # Salt used to hash the session id
- protected var session_salt = "Default nitcorn session salt"
-end
-
-redef class Int
- # Salt and hash and id to use as `Session.id_hash`
- private fun to_id_hash: String do return (self.to_s+sys.session_salt).md5