设置会话到期时间

How can I set the session expiry time to 10 minutes for the whole of my site? I cannot use the php.ini as its on shared hosting.

Is there a global method I could use?

I don't think so.

You can save the timestamp of the last refresh of your website into a session and compare it with the current time on the next reload.

if(isset($_SESSION['expiretime'])) {
    if($_SESSION['expiretime'] < time()) {
        //logged out
    }
    else {
        $_SESSION['expiretime'] = time() + 600;
    }
}
//maybe add some login procedures and than execute the following line
$_SESSION['expiretime'] = time() + 600;

Realy tricky subject , you can use the following :

session_set_cookie_params(600);

Witch actualy sets the cookie params , so the cookie expires after 10 min , when the user makes a request the browser whont send the phpsessid cookie so php will issue a new session . The problem is that it whont unset the previous session so the previous session will still be valid .

session_set_cookie_params