How to set cookie for other domain

Discussion in 'PHP' started by vinoth.t, Feb 1, 2010.

  1. #1
    Hi All,
    I want to set cookie for domains like x.com from my local host. Is it possible if it is so how can I do it
     
    vinoth.t, Feb 1, 2010 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You cannot, of course. It would be a massive security problem if one site could manipulate cookies for another site.
     
    SmallPotatoes, Feb 1, 2010 IP
  3. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So then how google handle same cookie for google.com, feedburner, youtube, orkut etc....
     
    vinoth.t, Feb 1, 2010 IP
  4. Skinny Vinny

    Skinny Vinny Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Most common is through ajax/js.
    The request is to the 2nd domain so that 2nd domains cookies are in play, and the call returns json or js vars with data.

    You can only see and set the cookie for the domain of the request.

    You can't overwrite or read another domains cookies.
     
    Skinny Vinny, Feb 2, 2010 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Look at the source for those pages and you will see they all request something (image, script, etc.) from the same domain.
     
    SmallPotatoes, Feb 2, 2010 IP