Hi, thanks for looking into this issue. I think in both cases, if the user clicks a link, that should take priority. So after both logout and session timeout, clicking a link should direct to that link after logging in.
My thinking is this: after logout, the user isn't actively in the middle of anything, so this is the simplest case and login should take them to the link. After session timeout, the user has chosen not to log back in and has instead taken action to click the link, this link should take priority over their previously visited page.
-Keith