session variables belongs to server-side scripting, thus javascript, being a client-side script is not able to set session variables. however, you are able to make use of ajax to set the session variable asynchronously, meaning without refreshing the page =)