Session_id size
Assume that seeion_id is evenly distributed and has a size = 128 bits. Suppose that every person on the planet is registered once a day with a constant session for 1000 years.
num_sesion_ids = 1000*365.25 *7*10**9 < 2**36 collission_prob < 1 - (1-1/2**82)**(2**36) β 1 - e**-(1/2**46) β 1/2**46
Thus, the probability of one or more collisions is less than one by 70 thousand billion. Therefore, the size of the session_id of 128 bits should be large enough. As mentioned in other comments, session_manager can also verify that the new session_id does not exist yet.
Randomness
Therefore, the big question, in my opinion, is whether session_id: s is generated with good pseudo-randomness. You can never be sure of this, but I would recommend using the well-known and often used standard solution for this purpose (as you probably already did).
Even if collisions are avoided due to verification, randomness and the size of session_id is important, so hackers cannot somehow make qualified guesses and find active session_id: s with high probability.
MrJ Jun 13 2018-12-12T00: 00Z
source share