Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Setting Cookies in ModuleSetting Cookies in Module
Previous
 
Next
New Post
10/22/2009 1:34 PM
 

This is very likely a dumb question (I'm certainly feeling dumb right now), but one of our developers is trying to set a cookie in a custom module so that the cookie value can be consumed by some client-side scripting.

In the module's Page_Load event, he's using the following code To set a simple cookie value:

  HttpContext.Current.Response.Cookies("foo").Value = "bar"

He's using the following as well to set a compound value:

   HttpContext.Current.Response.Cookies("foo")("bar") = 1
   HttpContext.Current.Response.Cookies("foo")("baz") = "wibble"
   HttpContext.Current.Response.Cookies("foo").Expires = Date.Today.AddHours(1)
 

These values can be see at load time by writing the contents of tpContext.Current.Response.Cookies to a textbox, but they do not show up as cookies on the rendered page.

What are we doing wrong?

I tried googling for cookies in DNN module development, but what I get back is the Privacy page of everyone doing module development. ;)

 
New Post
10/22/2009 4:36 PM
 

To make matters a little weirder, I had them look at the page load with Live Headers in FireFox, and I can see that the cookies are being sent down to the browser (see the red highlighting), but only the ones highlit in yellow are being seen by the javascript query.  The javascript we're using for reading the cookies is below.

http://localhost/dotnetnuke/jQtest.aspx

GET /dotnetnuke/jQtest.aspx HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 GTB5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost/dotnetnuke/Login.aspx?ReturnUrl=%2fdotnetnuke%2fjQtest.aspx
Cookie: .ASPXANONYMOUS=oHIeW9KJygEkAAAANWIyYzA0YjEtNTk5MS00NjY3LTg5M2ItYmMwMTIyYzdiNDI30; language=en-US; StyleSheetWidget_SizeWidget=width1024; StyleSheetWidget_TextSizeWidget=MediumText; authentication=DNN; .DOTNETNUKE=5CE103571124EA89D31E5EAAD0541B69A5D1F71257FBDCDB7CEE82B96718F1DEF17115019D51AB36FF84810C18066BAA5FFAE0AF15AE944536B97284EACCCF01; portalaliasid=AA5B803302FDBEF2DAFE5125CD8B82E0B021506E8618C864AD3FCC7F00A869F3EE04C90A4A880379618C493C9A77A1A4DA9A2A7666944DDE0624E010A691ED71A9F0130F5F4F9331; portalroles=; foo=153013034
Cache-Control: max-age=0

HTTP/1.x 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.0
Set-Cookie: language=en-US; path=/; HttpOnly
Set-Cookie: language=en-US; path=/; HttpOnly
Set-Cookie: foo=378597374; path=/; HttpOnly
Set-Cookie: nxcm=x=378597374&y=1; expires=Thu, 22-Oct-2009 06:00:00 GMT; path=/; HttpOnly

X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 22 Oct 2009 17:54:01 GMT
Content-Length: 56173

 

javascript for reading the cookies:

function readAll(cookieName ) { he value of all cookies is ' + document.cookie); }

 

 
New Post
10/22/2009 5:31 PM
 

I had them take HttpOnly off the cookie settings when I saw that, but we still aren't seeing the cookies.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Setting Cookies in ModuleSetting Cookies in Module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out