Re: SESSION variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KDawg44

    Re: SESSION variable

    On Aug 2, 6:38 pm, KDawg44 <KDaw...@gmail. comwrote:
    On Aug 2, 6:36 pm, KDawg44 <KDaw...@gmail. comwrote:
    >
    >
    >
    Hi,
    >
    I have a variable I would like to put in the $_SESSION array.
    However, I am not accessing this through a PHP script but am instead
    returning this to a javascript function through an AJAX call.  I need
    to set this as part of the session.  Can I either:
    >
    1.)  Set the session variable within the script that is called through
    the AJAX call.  Will I be able to call for this on successive pages?
    The page is accessed only through the AJAX call so will the SESSION
    variable be set properly?
    >
    or
    >
    2.)  Is there a way that I can pass the data received back from the
    AJAX call (in a javascript function) into a PHP function in the same
    document to then set it in the session?
    >
    The call is being made through the AJAX call and this cannot be
    changed.
    >
    Thanks for any insight.
    >
    Kevin
    >
    Okay, when I read my own question, I think #2 doesn't even make sense
    since PHP is server side and js is client side.  So, can #1 be done
    properly?
    >
    Thanks.
    Nevermind. Got it working correctly.

    Thanks!
  • KDawg44

    #2
    Re: SESSION variable

    On Aug 2, 6:54 pm, KDawg44 <KDaw...@gmail. comwrote:
    On Aug 2, 6:38 pm, KDawg44 <KDaw...@gmail. comwrote:
    >
    >
    >
    On Aug 2, 6:36 pm, KDawg44 <KDaw...@gmail. comwrote:
    >
    Hi,
    >
    I have a variable I would like to put in the $_SESSION array.
    However, I am not accessing this through a PHP script but am instead
    returning this to a javascript function through an AJAX call.  I need
    to set this as part of the session.  Can I either:
    >
    1.)  Set the session variable within the script that is called through
    the AJAX call.  Will I be able to call for this on successive pages?
    The page is accessed only through the AJAX call so will the SESSION
    variable be set properly?
    >
    or
    >
    2.)  Is there a way that I can pass the data received back from the
    AJAX call (in a javascript function) into a PHP function in the same
    document to then set it in the session?
    >
    The call is being made through the AJAX call and this cannot be
    changed.
    >
    Thanks for any insight.
    >
    Kevin
    >
    Okay, when I read my own question, I think #2 doesn't even make sense
    since PHP is server side and js is client side.  So, can #1 be done
    properly?
    >
    Thanks.
    >
    Nevermind.  Got it working correctly.
    >
    Thanks!
    Nevermind... I do NOT have it working correctly.... thought I did.

    It appears that setting $_SESSION['var'] in the script that is called
    by AJAX and then trying to retrieve it on another PHP page is not
    working.

    I guess I will have to use JavaScript cookies to accomplish my task
    unless anyone else can lead me any where else.

    Thanks.

    Kevin

    Comment

    • KDawg44

      #3
      Re: SESSION variable

      On Aug 3, 10:42 am, KDawg44 <KDaw...@gmail. comwrote:
      On Aug 2, 6:54 pm, KDawg44 <KDaw...@gmail. comwrote:
      >
      >
      >
      On Aug 2, 6:38 pm, KDawg44 <KDaw...@gmail. comwrote:
      >
      On Aug 2, 6:36 pm, KDawg44 <KDaw...@gmail. comwrote:
      >
      Hi,
      >
      I have a variable I would like to put in the $_SESSION array.
      However, I am not accessing this through a PHP script but am instead
      returning this to a javascript function through an AJAX call.  I need
      to set this as part of the session.  Can I either:
      >
      1.)  Set the session variable within the script that is called through
      the AJAX call.  Will I be able to call for this on successive pages?
      The page is accessed only through the AJAX call so will the SESSION
      variable be set properly?
      >
      or
      >
      2.)  Is there a way that I can pass the data received back from the
      AJAX call (in a javascript function) into a PHP function in the same
      document to then set it in the session?
      >
      The call is being made through the AJAX call and this cannot be
      changed.
      >
      Thanks for any insight.
      >
      Kevin
      >
      Okay, when I read my own question, I think #2 doesn't even make sense
      since PHP is server side and js is client side.  So, can #1 be done
      properly?
      >
      Thanks.
      >
      Nevermind.  Got it working correctly.
      >
      Thanks!
      >
      Nevermind... I do NOT have it working correctly....  thought I did.
      >
      It appears that setting $_SESSION['var'] in the script that is called
      by AJAX and then trying to retrieve it on another PHP page is not
      working.
      >
      I guess I will have to use JavaScript cookies to accomplish my task
      unless anyone else can lead me any where else.
      >
      Thanks.
      >
      Kevin
      Good again.... missing a session_start() ; on one of the pages....
      whoops...

      Comment

      Working...