Can a session variable be set to the contents of a function parameter using SET SESSION?
Use set_config() 

CREATE FUNCTION my_function(my_param INT)
RETURNS VOID AS $$
BEGIN
    perform set_config('myapp.myvar', my_param::text, true);
END 
$$
LANGUAGE plpgsql;