Why does this adp code work:
-
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
HTML
BODY
%
set host [string tolower [ns_set get [ns_conn headers $conn] Host]]
set jar [ns_getallcookies $conn]
set hits [ns_getcrumble $jar userinfo hits]
set lastvisit
It doesn't work becuase your ns_writes will already have sent the headers.
So your ns_sendcookie that adds them to the headers isn't getting sent
anymore.
In the ADP version, nothing is sent before the page is complete, as
streaming isn't turned on, which is qhy it works.
Send your cookies
It still does not work. Specifically, the .adp file will set a cookie,
but the .tcl file will not.
I simplified the code to the following:
adp:
%
set host [string tolower [ns_set get [ns_conn headers $conn] Host]]
set jar [ns_getallcookies $conn]
ns_setcrumble jar userinfo hits 100
I think that the first ns_write will send the headers. If you don't have
ANY ns_writes, headers don't get sent at all. If I recall correctly...
Thorpe Mayes said:
It still does not work. Specifically, the .adp file will set a cookie,
but the .tcl file will not.
I simplified the code to the
Okay. I think I see now. When using tcl, I have to do something that
will send some headers. I added an ns_return ... and it worked.
So does adp send headers in all instances?
Thank you for your help.
Thorpe
On Sep 23, 2005, at 8:37 AM, Bas Scheffers wrote:
I think that the first ns_write
On Fri, 2005-09-23 at 06:57 -0400, Thorpe Mayes wrote:
Why does this adp code work:
ns_sendcookie $conn $jar userinfo / [expr [ns_time] + 31536000] $host
but this tcl code not work:
ns_sendcookie conn $jar userinfo / [expr [ns_time] + 31536000] $host
In addition to ns_writes
Yes, ADP is the simple way of doing things that takes care of all this
stuff for you. I never use .tcl pages. The only time I use raw Tcl is
with a registered procedure, so I can have a pretty url like
/news/123.html rather than news.adp?id=123
Cheers,
Bas.
Thorpe Mayes said:
Okay. I think I
Thank you for laying this out for me. This information is very helpful.
Best regards,
Thorpe
On Sep 23, 2005, at 10:02 AM, Nathan Folkman wrote:
Below are a few design guidelines we usually try to follow, some of which might help make things easier:
1. Tcl procs should be as generic and