0

passing cookies

Hi,

I am having trouble getting a Cookie that I add to the response by my application to be received by the client browser.
Should I follow specials rules in addition to those found in the Cookie spec?

^ Ernest

7 Replies
  • QUOTE (ernest.micklei @ Aug 9 2010, 07:11 AM) <{POST_SNAPBACK}>
    Hi,

    I am having trouble getting a Cookie that I add to the response by my application to be received by the client browser.
    Should I follow specials rules in addition to those found in the Cookie spec?

    ^ Ernest


    Are you running into problems? Regular cookies should work.
    0
  • QUOTE (Jason @ Aug 10 2010, 02:42 PM) <{POST_SNAPBACK}>
    Are you running into problems? Regular cookies should work.


    This is the Http Header that I send in the response:

    Set-Cookie: login.email="me@here.com";version=1;domain=m.mysite.com;path="/"

    Anything wrong with this syntax?
    0
  • QUOTE (ernest.micklei @ Sep 6 2010, 01:15 PM) <{POST_SNAPBACK}>
    This is the Http Header that I send in the response:

    Set-Cookie: login.email="me@here.com";version=1;domain=m.mysite.com;path="/"

    Anything wrong with this syntax?


    You encoded it, correct? You probably don't want to use quotes and I don't think you can have a dot in the name like login.email.
    0
  • QUOTE (Jason @ Sep 7 2010, 04:32 PM) <{POST_SNAPBACK}>
    You encoded it, correct? You probably don't want to use quotes and I don't think you can have a dot in the name like login.email.


    So I tried another format with minimal information:

    Set-Cookie: a=b;version=1;path=/

    Still no luck :-( Could someone provide a working example?
    0
  • QUOTE (ernest.micklei @ Sep 8 2010, 01:19 PM) <{POST_SNAPBACK}>
    So I tried another format with minimal information:

    Set-Cookie: a=b;version=1;path=/

    Still no luck :-( Could someone provide a working example?


    Any help on this would be appreciated.
    0
  • Any custom cookies you create will be passed to Yahoo's servers. On each subsequent page view, Yahoo's servers will send the currently set cookies in each request to your server. What this means is that you can detect the cookie on the server side, but the cookie is never passed directly to the device itself. This is why you can't see your cookies using a desktop browser's inspector.

    There's a good reason for this: mobile devices have limits to the number of cookies being set, and some devices don't support cookies at all.

    Here's the rough process of how this is handled by our servers:

    1. Device requests a page from yourwidget.bpapps.com
    2. Blueprint server fetches the requested page (outputting Blueprint XML) from your server, passing all the current cookies to your server.
    3. Blueprint server delivers a custom rendering of the page directly to the device. Cookies set by your server are NOT delivered to the device itself.

    And a breakdown of how you would go about setting/getting cookies on the scripts running on your server (using PHP):
    1. index.php
    // set a cookie
    header('Set-Cookie: myKey=myValue'); // method 1
    setcookie("myKey", "myValue"); // method 2

    2. secondpage.php
    // get the cookie
    $cookie = $_COOKIE['myKey'];


    Hope this helps!
    0
  • Thank you so much. I was not aware of the info from Step 3.

    Since I did tryout many of the combinations for the cookie format, I think I can now conclude that the Yahoo server only accepts the old netscape style cookie (RFC2965 didn't work) format which means:

    - no version indication (version="1" didn't work)
    - do not quote the values (path="/" didn't work)
    - use an exact spelling of the Http header "Set-Cookie" (Set-cookie didn't work).

    ps: I am not using PHP so I had to figure this out for the framework I use instead.

    QUOTE (David @ Sep 29 2010, 04:05 PM) <{POST_SNAPBACK}>
    Any custom cookies you create will be passed to Yahoo's servers. On each subsequent page view, Yahoo's servers will send the currently set cookies in each request to your server. What this means is that you can detect the cookie on the server side, but the cookie is never passed directly to the device itself. This is why you can't see your cookies using a desktop browser's inspector.

    There's a good reason for this: mobile devices have limits to the number of cookies being set, and some devices don't support cookies at all.

    Here's the rough process of how this is handled by our servers:

    1. Device requests a page from yourwidget.bpapps.com
    2. Blueprint server fetches the requested page (outputting Blueprint XML) from your server, passing all the current cookies to your server.
    3. Blueprint server delivers a custom rendering of the page directly to the device. Cookies set by your server are NOT delivered to the device itself.

    And a breakdown of how you would go about setting/getting cookies on the scripts running on your server (using PHP):
    1. index.php
    // set a cookie
    header('Set-Cookie: myKey=myValue'); // method 1
    setcookie("myKey", "myValue"); // method 2

    2. secondpage.php
    // get the cookie
    $cookie = $_COOKIE['myKey'];


    Hope this helps!
    0
This forum is locked.

Recent Posts

in Blueprint General Discussion