SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,849
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Ajax, Cookies, Authentication...Newbie Questions

    I'm a complete newbie with respect to javascript and Ajax.

    I am building a form where registered users will put their employment histories. Each employment history will need to be associated with an employer ID, which is in my database. Instead of having tons of page reloads as users enter each employer in their histories, I figured I'd use Ajax to do it much more quickly.

    Then I realized that I wasn't sure if Ajax sent the user's cookie to the server and if it didn't, then I wouldn't be able to tell what the person's authentication status is, what they have access to (only their own records), etc.

    So I would like to know if Ajax sends cookies to the server. And if not, is it possible to send the cookie to the server with the Ajax request so I can ensure that people are adding and deleting from their own profiles only?

    I'm sort of building this system without the authentication piece in place as of yet (will come later). So I have no way of testing this. Which is why I am asking.

    Thanks for your assitance.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sort of building this system without the authentication piece in place as of yet (will come later). So I have no way of testing this.
    Sure you do. Create a html page that displays one button. Use the button's onclick event to set a cookie, and then on the next line of js code make an xhr request to the server. Have your server side script attempt to get the cookie value and then send the cookie value back as the response. Then alert() the responseText.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •