Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can an include retrieve a cookie created by the calling include? 3

Status
Not open for further replies.

Coder7

Programmer
Oct 29, 2002
224
US
Hello.

(background: this involves 2 include files that are saved as .asp files but are located in the INCLUDES folder).

I have an include file (call it 'include1.ASP') that calls a sub which processes the display of error information by doing a response.redirect (with a query string to pass error info) to another include file (call it 'error.ASP').

I need to pass some additional info from include1.asp to error.asp which I cannot pass by adding it to the response.redirect query string for reasons due to the nature of the additional information that I need to pass.

I am trying to create a cookie on include1.asp and
retrieve it from error.asp but I am not getting any value on error.asp for the cookie.

Is it possible to do what I'm trying to do?

Thanks all for any help and have a great weekend :)



 
why a redirect to an include? why need cookies

Code:
<%
if ok then
%>
<!--#include virtual="/include/okpage.asp"-->
<%
else
%>
<!--#include virtual="/include/error.asp"-->
<%
end if
%>

[code]

this way there is no transfer, all the variable etc are already on the same page.


Chris.

Indifference will be the downfall of mankind, but who cares?
[URL unfurl="true"]www.candsdesign.co.uk[/URL] A website that proves the cobblers kids adage.
[URL unfurl="true"]www.cram-system.com[/URL] Nightclub counting systems

So long, and thanks for all the fish.
 
Hi Chris.

Great point, however.........

I support an application written by others so I cannot answer the 'why' part and now isn't the time for me to go through the application to determine what I'd have to do to make your suggested change, but I've added your suggestion to my list of things to look at as definite future improvements to the application. Right now I have to work with it the way that it is.

Is it possible to get the cookie value to pass from include1.asp to error.asp? I'm getting nothing with my request.cookie on error.asp.

Thanks for any help.

 
provided the domain name doesn't change the cookie should be accessible.

one thought just struck, Cookies won't be created if any headers have been sent to the browser. so the response.cookies() must be before the <html> tag on the creating page.

the request.cookies() can be anywhere in the page however.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Hi again Chris.

Thanks for the html tag heads up.

There is no html on include1.asp where i'm creating the cookie and error.asp was a static html page to which i added scripting to retrieve the cookie value (in theory hahaha) from include1.asp.

I'll play with this some more but I have to have it figured out by next Monday afternoon to meet the code review deadline.

I did a response.write on include1 of the cookie value after i created the cookie and the value is correct but there is nothing on error.asp when i do a response write to display the value of the retrieved cookie.

 
In my own opinion, if you cannot pass the additional information via querystring, passing it by cookies is only slightly less open (since the data will be sent in the headers to the client, then back again). You may be better off writing the values to some session variables so that they never leave the server.

As far as the current method you are using, there shouldn't be any problem in passing the information using cookies as long as you set those cookies before you do the Response.Redirect. Double check your syntax, make sure your etting the value in Response.Cookies and printing the value from Request.Cookies
Also, you should be getting an error when you print from Include1 when it gets to the Response.Redirect, if you aren't receiving an error then the code is not getting there.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
another "trick" you could use, if the include files aren't used for functions, just for output...

<script src="include1.asp"></script>

then could generate the "include" file a little more dynamically than a true include.

and you could put the handling code for uploading files / whatever in one of these files.


[thumbsup2]DreX
aKa - Robert
 
Thanks all for the really great input! Let me digest all of this.

Hope you had a great weekend and that you have a really great week.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top