On Mon, 2005-10-17 at 14:18 -0400, Jonathan wrote:
> I ran into this issue:
> 
>       If I try to tie with a session id that doesn't exist in the db,
> the app catches an Apache::Session die

The standard approach here is to eval{} that and if it throws an
exception you check to see if it's the one from using an unknown ID or
something else, and if it is you try to tie again with an empty ID.

> Ideally:
> 
>       If I try to tie with a session id that doesn't exist in the db,
> the app rewrites the session id to null (which generates a new
> session id)

That's basically what I'm describing above.  Just use the exception as a
signal that the session ID is not in there.

> I can't figure out how to do this with Session::MySQL cleanly - the
> only idea that I've come up with is pre-caching the db handle and
> doing a SQL select to see if the record exists  -- but then I end up
> making 2 sql queries for the session data when 1 is really all that
> should be necessary.

This is not as good as catching the exception, since you do two queries
all the time instead of only when you need to.

- Perrin

Reply via email to