AJAX and session

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

    AJAX and session

    I am having difficulty on maintaining session when using ajax.

    I first load a page with a session genterated. But since AJAX is a
    client side
    activity where I sent an AJAX request to an url without any session
    info. Of course, the server will create a new session. Even though I
    can write
    the session id into the first page where I made ajax calls, it is not a
    secure way...

    How do people deal with this problem?

    thanks

    Jim

  • aaron.reese@tiscali.co.uk

    #2
    Re: AJAX and session

    I am struggling with a similar problem.

    I am writing an on-line application that, once you have logged in,
    will be all ajax calls within the same page. Hitting refresh will
    completely bllx the application because the page will return to its
    original state so I am planning to generate a session ID and store it
    in the HTML as a hidden div when you log in and store it in a database
    (additional data will be linked to the session ID record).

    Every time you go to a new 'page' (still the same web page but a
    different part of the application), I am going to pass the sessionID
    through as part of the URL. This will then update the session record
    in the database to say where you are in the application. If the user
    hits refresh, the PHP will intercept the sessionID and call the
    relevant functions to load the correct 'page'

    In order for the refresh to work correctly, the sessionID needs to be
    included in the HTTP_GET_VARS or $_POST when the page loads so it has
    to be generated on the log in screen and passed to the main
    application.

    I have not yet tested this so it is all theory...

    Does this give you a heads up on your problem?

    Comment

    Working...