Cookies examples

87 views
Skip to first unread message

ATK

unread,
Sep 1, 2014, 11:20:37 PM9/1/14
to wub-dis...@googlegroups.com
Can someone kindly post an example of send and receive cookies?
I am trying out the following without success;

            set cookie_name "-domain .koroma.co.za -name mystuff -path /mystuff -value datagnius -changed 0 -when [clock seconds] -secure 1}"
            set cookie_name [Cookies::parse4client $cookie_name]
            Cookies::new $r $cookie_name mystuff no123456xy9049

"cookies" is still not set in response dict ( -cookies {} )

It's my first time ever trying to use cookies...I don't know what am doing.

Colin McCormack

unread,
Sep 2, 2014, 12:08:23 AM9/2/14
to wub-dis...@googlegroups.com
Have a look at the end of Utilities/Cookies.tcl, there are some unit test sort of things.

Assuming $r is a request dict:

This sets:
set r [Cookies Add $r -path $cpath -expires $expires {*}$cookie_args -name $name -value $id]

This retrieves:
set id [Cookies Fetch? $r -name $name] 

Colin


--
You received this message because you are subscribed to the Google Groups "Wub Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wub-discussio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ATK

unread,
Sep 2, 2014, 1:31:52 PM9/2/14
to wub-dis...@googlegroups.com
Thanks, it works...

I set it as follows;
        set r [Cookies Add $r -path /mystuff -expires [expr [clock seconds]+1440] -name mystuff -value BPX77740493KG]

I could see it in the request dict;
  -cookies {{{} {} mystuff} {-value BPX77740493KG -name mystuff -version 0} {{} /mystuff mystuff} {-path /mystuff -expires {Tue, 02-Sep-2014 16:37:15 GMT} -name mystuff -value BPX77740493KG -changed 1}}


Mozilla stores its cookies in a sqlite3 database (moz_cookies table). The above cookie was set;;
  15366    localhost    0    0    mystuff    BPX77740493KG    localhost    /mystuff    1409675835    1409674395564569    1409674258950109    0    0

The following returned the value of "-value"
  puts "CookiesFetch-> [Cookies Fetch? $r -name mystuff] "
CookiesFetch-> BPX77740493KG
Reply all
Reply to author
Forward
0 new messages