i have set a session variable like this in index page if(!isset($_SESSION['adpages'])) $_SESSION['adpages'] = 0; i have another php for simple ajax example like when i click a button it calls ajax.php if(isset($_SESSION['adpages'])) { $_SESSION['adpages'] = $_SESSION['adpages']+ 1; echo "here".$_SESSION['adpages'] ; } else { $_SESSION['adpages'] = 0; echo "here not ".$_SESSION['adpages'] ; } but it always showing here not 0 any idea to fix this