How to add onclick event to a link?
Links do not allow any callback action, you can not set a variable on click event.

Instead you can either make it a custom form, where submit button is themed to look like a link instead of link and on form submission set the value in session.

Or other way would be, if its not secured information, you can pass it as query parameter in URL.