views:

249

answers:

1

I have an app that is run from a compiled DLL on a web server. I need to do some Single Sign On (SSO) integration with the app, and the only way I can "inject" functionality, is to modify an external JavaScript file that gets referenced.

In the JavaScript file are some code blocks to set cookies with the session ID of that App. I tried adding more code to add more cookies so I could read the cookies from another sub domain, but the cookies don't get set!

I call the exact same cookie set function with a different name and it doesn't work. I debugged with FireFox and watched the JavaScript code get called for my new cookies, but still, no new cookies!!! I even see the existing cookies being updated!!! What gives!

Can anyone save my sanity!?!?!?

Here is the cookie setting function:

function setCookie (name,value,expires,path,domain,secure) 
{
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

And here is the code that calls it:

var twoHours =  1800*1000;
var expDate = new Date();
var secondExpire = expDate.getTime();
expDate.setTime(expDate.getTime() + twoHours);

setCookie("mysession",123456789,expDate,"/",null,false);    
setCookie("mylastConnect",secondExpire,expDate,"/",null,false);
A: 

Try setting the domain to ".exemple.com". This should make the cookie accessible for all subdomains of exemple.com (but not to http://exemple.com, you'd have to put a second cookie).

Also check your browser's cookie settings, but I assume you've done that.

streetpc
Yeah that's not the problem. I am just trying to set the cookies and that wont even work, let alone trying to read them from another subdomain.
SkippyFire
Well your exact code works for me in Firefox...
streetpc