• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method to Retreive Cookies from Client

 
Richard Parker
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am looking for a good method to retrieve a cookie from the client machine.

I'm attempting to do an auto-sign on into a Java web application using the following method(This is all done on a Windows machine with IE):

------
1. Java web application redirects to an ASP page (running on a different web server).
2. The ASP page gets the Windows Log On credentials from the server and writes the username to a cookie on the client machine (this cookie will expire in 10 seconds)
3. The ASP redirects back to the Java web application.
--------------------------------------------
This is the part that I'm having trouble...
--------------------------------------------
4. The Java application reads the cookie to access the username.

... (other stuff is done w/ the user name)...

-----
From this post:
http://www.coderanch.com/t/292531/JSP/java/retreive-saved-cookies

I see that:

Java is running on the server, and can not access the client file system to read the cookies.
...
You can not access all the saved cookies on someones system via JSP/Java.



Ok - so if JSP/Java can't access the client's cookies - is there another method that can? Javascript perhaps?

How can I get the information from the cookie written by an ASP page (running on a different server) into my Java app?

I'm stumped.


All responses to this post are very much appreciated and I thank you in advance.

Sincerely,
Richard Parker
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For security reasons, Javascript isn't going to let you read cookies from another domain.
 
Richard Parker
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response Ben!

I believe you can set a cookie for a particular domain in ASP:

--------
Response.Kookies("UID")=1
Response.Kookies("UID").Domain = "myserver.com"
-------

Of course, this didn't seem to be working for me.
(ie. wasn't writing the cookie at all to the client)

However assuming it *did* work - I'm hoping that perhaps using Javascript running on "myserver.com" would be able to do this.

If anybody has any other suggestions, thoughts or experience doing this, I'd greatly appreciate it. Otherwise I'll mosey on over to the very sketchy land of ASP and try posting this question over there.

Thanks,
Richard
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can move this to our HTML/Javacript forum for you if you like.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!