The easiest solution is to not create a session for the search engines bots and, if possible, to avoid logging in at the beginning of the browsing but rather to wait for an ID.
To set up this technique, you will find many codes here : Sessions and SEO.