Forum OpenACS Q&A: lynx cookie patch

Collapse
21: lynx cookie patch (response to 1)
Posted by Connie Hentosh on
Making the following changes in ad-utilities.tcl.preload permits lynx users to login. Modify ad_set_cookie to add quotes around the value:
    set cookie "$name="$value""
And then modify ad_get_cookie to look like this:
    if { $include_set_cookies == "t" } {
        set headers [ns_conn outputheaders]
        for { set i 0 } { $i < [ns_set size $headers] } { incr i } {
            if { ![string compare [string tolower [ns_set key $headers $i]] "set-cookie"] && 
                    [regexp "^$name="([^"]+)"" [ns_set value $headers $i] "" "value"] } {
                return $value
            }
        }
    }

    set headers [ns_conn headers]
    set cookie [ns_set iget $headers Cookie]
    if { [regexp "$name="([^"]+)"" $cookie match value] } {
        return $value
    }
    if { [regexp "$name=([^;]+)" $cookie match value] } {
        return $value
    }
If you dont need to be backward compatible with older cookies set previous to the patch... then you can omit the last if statement.