you are right that you can't use php functions with onchange events. this is because php is server side, meaning that its processed by the server before being sent to the browser. javascript is client side. what you need to do is get ajax(pretty much javascript) to send info to the php script where the session will be set.