The algorithm ought to treat unknown or expired session IDs as invalid and proceed to authenticate the user before generating a new, unique, valid session ID for the new session. This way there'd be no need to involve a potentially irritating time-out problem. A timeout should probably be used after repetetive failures to authenticate the user properly.
Also, by the very definition of a session, a session ought to expire after a certain period of inactivity, otherwise one could just do away with the need for sessions IDs to identify a "session" as a period of continuous involvement with the application and we could term the ID as a client ID instead as there'd be little or no variance.
perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er