session problem

Discussion in 'PHP' started by chxxangie, Nov 20, 2007.

  1. #1
    
    session_start();
    ini_set("session.gc_maxlifetime", "10");  //in second
    
    if(isset($_SESSION['active'])){ 
    }else{
    	session_unset();
    	session_destroy();
     	?>
    	<SCRIPT LANGUAGE="Javascript">
    		alert ('Your sesion has expired.\nPlease login again!'); 
    		document.location = "login.php"
    	</SCRIPT>
    	<?php
    	exit;
    }
    ?>
    
    PHP:
    i want to destroy the session if the user do not have respone in a period of the time.
    i search from internet is the above code.
    but when i trying it doesn't work?
    do i miss something or...???
     
    chxxangie, Nov 20, 2007 IP
  2. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does it shows the error message (javascript alert), or not? If not, the if statement seems to be not working. Else, try using session_unregister('global-session-variable-name'); :)
    Also you could try using session_destroy() only.

    edit: this helps with me: - this code removes unnecessary cookies.
    
    if (isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time()-42000, '/');
    }
    
    PHP:
     
    DeViAnThans3, Nov 21, 2007 IP