Save JavaScript Cookies in ASP Cookies - Posted (1971 Views)
Junior Member
mafifi
Posts: 308
308
I have a web page that pulls information from different applications on diffrent servers. One such application sends JavsScript cookies data to the client. Is it possible to grab these values and stuff them in ASP Session Variables or Cookies? I would love to see a working sample.
Regards,

Mo
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Forum Admin
HuwR
Posts: 20611
20611
not sure what you are after, a cookie is a cookie it is a text file saved on the users machine they are language agnostic so you can just read them using ASP the same as you can read them using javascript
Posted
Junior Member
mafifi
Posts: 308
308
Originally posted by HuwR
not sure what you are after, a cookie is a cookie it is a text file saved on the users machine they are language agnostic so you can just read them using ASP the same as you can read them using javascript

This is what I am trying to do:
Code:


<script language="javascript" type="text/javascript">
document.cookie = "mycookie=2; expires=1/1/2020; path=/;";
</script>


<%
Dim myBrownie
'get the cookie
myBrownie = Request.Cookies("mycookie")
Response.Write("You ate " & myBrownie & " brownies")
%>

I do not see the value of the cookie until after I refresh the page.
Regards,

Mo
Posted
Forum Admin
HuwR
Posts: 20611
20611
well you won't because the asp code gets executed on the server before the page is sent to the client and then the javascript runs. so there is no cookie at the time request.Cookies is called
Posted
Junior Member
mafifi
Posts: 308
308
This is the problem which I am trying to resolve. I am thinking about using Ajax to refresh the page and pull the cookie value(s).
Regards,

Mo
Posted
Forum Admin
HuwR
Posts: 20611
20611
maybe if you explain what you are trying to achieve we can offer suggestions, writing a cookie from the client and then trying to read it from the server without a postback just won't work, so what exactly are you trying to accomplish ?
Posted
Junior Member
mafifi
Posts: 308
308
Here's what I would like to happen:

Application 'A' (Non ASP) will authenticate the user and send the 'User Information' to application 'B' (ASP) as JavaScript cookies. I want to delete the JavaScript cookies as soon as I am able to hold their values in ASP session variables and some of the 'User Information' will be encrypted and saved in a persistent ASP cookie to be used as needed throughout the application.
Regards,

Mo
Posted
Support Moderator
Shaggy
Posts: 6780
6780
As Huw said, cookies operate independent of language so you could set the cookie in application A before transferring to application B which would then be able to read the cookie.
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Forum Admin
HuwR
Posts: 20611
20611
I'm still not following what you are trying to do,
You can't send information form A to B as javascript cookies, cookies are NOT javascript cookies are text files stored on the clients machine.
What is application A ? if it is able to write a cookie, then application B can just read them using ASP (by the way ASP is not a language either so can be vbscript or javascript), what are you trying to do exactly, pleasse explain more.
 
You Must enter a message