Frequently Asked Questions

Mar 29, 2024 - 03:18am

 [F] Frequently Asked Questions  / Support Assistant  / What does (is)...  / ...a macro, or template, or WCTL?  / WCTL  /

How do I set or read a cookie within Web Crossing?

Rate This FAQ
 (Not yet rated)

Created On: 23 Dec 1998 6:15 pm
Last Edited: 7 May 2001 3:12 pm

Question Printer Friendly

Reading cookies is done with the evirCookie() directive, setting cookies is done with the addResponseHttp() directive.

Answer

To read a cookie use something like:

%% set theCookie envirCookie( "webxUser" ) %%

To set a cookie, use something like:

%% set cookieData randomString.toUrl %%
%% set theCookie "Set-cookie: webxUser="cookieData "; expires=Friday, 31-Dec-2010 23:59:59 GMT; path=/" %%
%% addResponseHttp( theCookie ) %%

To use your own cookies for authentication, use the authenticateFilter macro to handle the authentication, that will override the built-in methods.

If you're having trouble reading cookies, you may have to set the domain in the cookie explicitly. This has nothing to do with Web Crossing but is a function of how browsers read cookies, and is part of the "cookie security protocol". Some browsers are more stringent than others...and if you use subdomains this may be a requirement.

Related, you may also need to set the "Domain for Cookies" in the "Registered Users" control panel. If you use subdomains (for example "forums.mysite.com") you should set this to ".mysite.com"