session variables in ajax call

Discussion in 'PHP' started by chandan123, Dec 26, 2009.

  1. #1
    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 :p
     
    chandan123, Dec 26, 2009 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Do you start the ajax.php with function session_start()??
     
    s_ruben, Dec 26, 2009 IP
    chandan123 likes this.
  3. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the same qurestion?
     
    astkboy2008, Dec 26, 2009 IP
    chandan123 likes this.
  4. chandan123

    chandan123 Prominent Member

    Messages:
    11,586
    Likes Received:
    578
    Best Answers:
    0
    Trophy Points:
    360
    #4
    yeah i realized that after posting here that was the problem :D and i fixed that ;) thanks for reply :)
     
    chandan123, Dec 26, 2009 IP