Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies & Frames

Status
Not open for further replies.

jillallynwilson

Programmer
Apr 14, 2004
21
US
I having problems with setting and reading my cookies within a frameset. If I access the site/catalog outside the frameset the cookies work fine.

I read the post ( )and ensured that my cookie was set correctly. However, I think my issue is that my site/catalog is being displayed within another company's e-Procument frame.

Does anyone have any suggestions on how I can get around this?

Thank you in advanced.
 

You need to confirm whether your site is or is not being displayed within someone elses frameset.

If it is, try using frameset breakout code. If not, then you'd need to post some code.

Hope this helps,
Dan

 
Yes, Dan - Our site is being displayed in someone elses frameset.

I am not familar with frameset breakout code. Can you supply some examples?

Here is my code for working with our cookies, which works great outside of the other company's frameset:

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" : "");
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function DeleteCookie (name,path,domain) {
if (GetCookie(name)) {
alert("Delete Cookie");
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function SetValue() {
var cvalue = GetCookie("cartid");
if (cvalue==null) {
var exp = new Date();
exp.setTime(exp.getTime() + (30*24*60*60*1000));
SetCookie("cartid",this.document.forms[0].OrderUniqueID.value,exp,"/");
}
else {
this.document.forms[0].OrderUniqueID.value=cvalue
}
}

___________

Thanks - Jill
 

Something like this in your top-level page should break you out of any frameset:

Code:
if (top.location != location) top.location = location;

Hope this helps,
Dan

 
Thanks again Dan -

This is very helpful. One last question, where would this code go. My first thought would be in general JavaScript tag. Like:

<SCRIPT LANGUAGE="JavaScript">
<!--
if (top.location != location) top.location = location;
// -->
</SCRIPT>

so that the location is properly set for all functions for the page.

Is this correct?
 
Dan -

I added the above code and it actually takes me out of the user's frameset, which is not allowed. They require us to stay within their frameset. Anyother thoughts?

Thanks again
Jill
 
You're probably out of luck. Since you're within someone else's frameset, it sounds like you're running into a cross-domain security issue (i.e. you cannot access cookies that are not in your own domain).


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top