Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Cookie handling (basic)
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

dayve
Forum Moderator

USA
5820 Posts

Posted - 01 December 2004 :  16:27:21  Show Profile  Visit dayve's Homepage
quote:
Originally posted by Tiggerz

http://www.w3schools.com/asp/asp_cookies.asp

At the very top its says Response.Cookies must appear before the html tag.

I don't know why they would state that unless they're doing it for explicit reasoning, but I am telling you once again, it does NOT have to be. Did you even try my test? I already proved the point about the cookie issue.

I'd love to see the script you're having problems with. I'm willing to bet there is something else causing your problem.


Edited by - dayve on 01 December 2004 16:42:17
Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 01 December 2004 :  18:20:06  Show Profile
yes, I tried your test - it didnt work. I just got a property ready only error on the bit where you assign a value to the cookie.

For me I can only do ("mycookie")("field") = aValue
If I try and do ("mycookie") = aValue I get a read only error.

When I change it to the line that works, I get no value from Request.Cookies and Response.Cookies does not save a value if I readload the page).

Edited by - Tiggerz on 01 December 2004 18:23:47
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 01 December 2004 :  18:26:11  Show Profile  Visit dayve's Homepage
It's your server and/or client settings.

What browser are you using? Have you tried another browser besides your default one. What hosting company are you using?

Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 01 December 2004 :  23:41:26  Show Profile
IE 6.x IIS 5 winxp sp2, .net 2k3 local machine.
vb script 2.5

That issue is mentioned on quite a few forums if you google for it as well as WC3.
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 01 December 2004 :  23:43:21  Show Profile  Visit dayve's Homepage
doesn't matter... the problem is only happening with you. I've used and tested using cookies many times over on different machines and never had a problem like you're describing. if you post your script I assure you I can get it working without putting the cookie info before the html tag.

Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 02 December 2004 :  01:24:25  Show Profile
Its working now :)

So why would W3C post up an issue that I was duplicating if its not true.
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 02 December 2004 :  05:32:29  Show Profile  Send pdrg a Yahoo! Message
maybe to try to prevent these problems - if your buffering is (programatically/serversideically) set to FALSE then you would get the errors you are seeing whereas dayve wouldn't necessarily if his was set to TRUE.

As the data has to be passed in the header, and w3c define the standards of HTML then saying the cookie should be sent before the <html> tag is true, and it is a feature of IIS (and other servers by the sounds of it) that they will buffer and so allow the cookie value to be set anywhere in the page. However, to be on the safe side (maybe you decide to take your app and convert it to python and run it on a myfreewarelinuxcompatiblebasicasallheckwebserver) follow the standards, set the cookie before the <html> tag, and your code will be standards-compliant and more robust and supported because of it.

Anyone disagree? There are both gains and risks developing for version-specific extensions to protocols, so where possible, follow the standard. IMVHO, of crs
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 02 December 2004 :  11:34:14  Show Profile  Visit dayve's Homepage
my server settings are not tweaked so everything is in a default fashion. I am not disagreeing where a response.cookie should be placed, I am merely stating that it can be done. W3C standards does not mean it is law. Internet Explorer has proven otherwise that things work when they should not. Heck... people still use HTML tags incorrectly and their sites still work.

my point was, and still stands, that Tiggerz issue is a matter of server/client settings OR other code portions in his script preventing him from doing what he wanted to do. I'd still love to see the script he is having difficulty with.

Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 03 December 2004 :  06:24:50  Show Profile  Send pdrg a Yahoo! Message
yeah - would be interesting to get to the bottommost bit of this one!
Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 04 December 2004 :  02:34:46  Show Profile
I suspect that it is a server setting, because just thinking I have javascript code that uses cookies all over the place and I dont ever remember having to do it before the html tag. Being the script code is running on the same server that this vbscript code is running, I suspect its more to do with a server side asp setting rather than anything else.
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 04 December 2004 :  11:53:45  Show Profile  Visit dayve's Homepage
Tiggerz... post your code in a text file and I'm sure we can pinpoint something, otherwise we can do nothing but continue to speculate as to the cause of the problem.

Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 04 December 2004 :  16:47:10  Show Profile
its working now.

If you google on the term 'asp cookies before html' then you will find out why it needs to be done before the html tag. But in general its because the cookie collection is written out to the client with the headers. Hence before the <html> tag as that sends the header.

I suspect you could do it after, but you'd need to send out more headers (a redirect would do that).
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 04 December 2004 :  23:07:25  Show Profile  Visit dayve's Homepage
I know it's working, I just want to see what your coding lookes like so I can give some advice.

Go to Top of Page

Tiggerz
Starting Member

45 Posts

Posted - 04 December 2004 :  23:59:40  Show Profile
I used your code example, but just moved the response.cookies b4 the html tag. Your example doesnt actually create a cookie file on disk, which is what I was on about. It just updates memory.
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 05 December 2004 :  01:26:25  Show Profile  Visit dayve's Homepage
again, if you would show your code... ahh, forget it. you're missing the point.

Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07