With out seeing this code in context with the rest of the page, it is dificult to say what is wrong.
It looks correct to set the session variable on page load assuming that it occurs after the recordset code.
If you page has a form on it that submits to itself,. the form could be resetting the session variable when it submits. If the Recordset is filtered, the form may not pass the variabel the recordset needs. In this case, the session variable will be set properly when the page loads, but reset to blank when the form submits.