Pass cookies in URL?

14,714

You can't pass cookies in the URL. You can pass session ID if server supports it. Java Servlet containers do support it (it's in Servlet spec) by using jsessionid path parameter. Just make sure ;jsessionid=... is right after the path, before query (it's called "path parameter" for a reason).

To your questions:

  • servlet containers do support jsessionid path parameters. In general, you can't pass any cookie this way.
  • Yes, path parameters start with semicolon.
  • No, those are not cookies. You can have multiple path parameters (separated by semicolon), but they won't be visible as cookies on the server side.
Share:
14,714
Vinnie
Author by

Vinnie

Updated on June 04, 2022

Comments

  • Vinnie
    Vinnie almost 2 years

    I'm trying to do a file upload in Flex using it's FileReference class.

    This works great in IE, but bombs in FireFox and Chrome. The issue is that Flex starts a new process for the POST but does not pass the authenticated user cookie with this request. The server gets the request, but attempts a redirect to the login page and... BOOM - 2038 Error!

    I read here that I can pass the cookie information in the URL. I have not gotten this to work yet. Here are my questions:

    • Is this a standard feature in all servers to accept cookies in the URL (ours is Glassfish)?
    • Does the cookie portion of the URL start with the semi-colon (";")?
    • Can I add more than one cookie value and are those also delineated with semi-colons?
  • Vinnie
    Vinnie over 12 years
    Thanks, but in my case we use OpenAM and I need to pass the OpenAM cookie. I may be stuck.
  • Peter Štibraný
    Peter Štibraný over 12 years
    You should probably ask question about OpenAM specifically, someone will surely help you. I don't know anything about it though.
  • Peter Štibraný
    Peter Štibraný over 12 years
    Btw, in Tomcat, you can have "Valve" that processes your request -- it could take path parameters and convert it to cookie objects in requests. Maybe you can do something similar in Glassfish? (Simple filter won't do since it cannot add cookies. You need low-level access to Tomcat/Glasfish internals to add cookies to request).