I've never tried using session_start() inside a function.
If you start the session outside of the function (in the main page or a file included in the main page) then you can use session variables within the function as long as you define them as global variables or pass them to the function:
function idle_time() {
global $user_name, $password;
if(empty($user_name) || empty($password)...
}
or
function idle_time( $user, $pass ) {
if(empty($user) || empty($pass)...
}
If you pass the variables to the function using the function parameters, remember that you have to call the function like 'idle_time( $user_name, $password)' but you can simply call it like 'idle_time()' if you define the variables as global within the function.
Hope this helps!
-Rich