I have a simple html document I have been using for some time on my
(i.e.) abc.com domain that uses cookies. I recently purchased a new
domain name and set up a service to redirect my new domain (i.e.)
xyz.com to a sub-directory of the abc.com domain. In other words, when
someone goes to URL xyz.com, they really end up in abc.com/xyz
directory but the MSIE browser says they are xyz.com.
The problem is that cookies quit working in this setup when I copied
the same HTML document in the /xyz subdirectory that xyz.com now
accesses. I can't set or get a cookie any longer by calling the
document.cookie function from JS any longer. The call does not fail
but the data is always blank. I even tried setting the cookie and from
the next line of code reading it back immediately and it still would
not save the cookie.
Anyone know how to fix this?
I checked the value of location.host, .hostname .pathname,
document.domain and they all indicate I am really at abc.com even
though the address in my IE browser says I am at xyz.com. 12 7781
Don Juan wrote: I have a simple html document I have been using for some time on my (i.e.) abc.com domain that uses cookies. I recently purchased a new domain name and set up a service to redirect my new domain (i.e.) xyz.com to a sub-directory of the abc.com domain. In other words, when someone goes to URL xyz.com, they really end up in abc.com/xyz directory but the MSIE browser says they are xyz.com.
Do not use frames for redirection. Use server settings, for example.
The problem is that cookies quit working in this setup when I copied the same HTML document in the /xyz subdirectory that xyz.com now accesses. I can't set or get a cookie any longer by calling the document.cookie function from JS any longer. The call does not fail but the data is always blank.
You cannot read or change cookies that are from a different second-level
domain. The Same Origin Policy does not care about that you own both
second-level domains; they are different to it, and access is denied.
I even tried setting the cookie and from the next line of code reading it back immediately and it still would not save the cookie.
That is weird, though. You should be able to set, modify and read the
cookies for the site from the same site. Exactly how are you doing that?
I think it would be best if you posted the URL of your "old" domain.
Anyone know how to fix this?
Probably.
I checked the value of location.host, .hostname .pathname, document.domain and they all indicate I am really at abc.com even though the address in my IE browser says I am at xyz.com.
document.domain does not indicate anything. Instead, you have to _set_
document.domain in order to access documents or cookies from a different
domain, but the same second-level domain.
PointedEars
function createCookie(na me,value,days)
{
if (days)
{
var date = new Date();
date.setTime(da te.getTime()+(d ays*24*60*60*10 00));
var expires = "; expires="+date. toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+ expires+"; path=/";
}
function readCookie(name )
{
var nameEQ = name + "=";
var ca = document.cookie .split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c .length);
if (c.indexOf(name EQ) == 0) return
c.substring(nam eEQ.length,c.le ngth);
}
return null;
}
document.write( '<br>location.h ref: ' + location.href)
document.write( '<br>location.p rotocol: ' +
location.protoc ol)
document.write( '<br>location.h ost: ' + location.host)
document.write( '<br>location.h ostname: ' +
location.hostna me)
document.write( '<br>location.p athname: ' +
location.pathna me)
document.write( '<br>document.d omain: ' + document.domain )
document.write( '<br>document.r eferrer ' +
document.referr er)
document.write( '<br>read cookie test: ' +
readCookie("tes t"))
document.write( '<br>set cookie test : ' +
createCookie("t est","DVT",3))
document.write( '<br>read cookie test: ' +
readCookie("tes t"))
Don Juan wrote: [code]
Your code, although it is unnecessarily inefficient and badly formatted,
works fine here[1], provided that I remove the newline after the
`return'[2]. Either you have included the newline, thereby returning
`undefined', or you have accidentally blocked cookie access for your new
site.
It would have been nice (and appropriate) if you had referred to anything
[3]
PointedEars
___________
[1] Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.2)
Gecko/Debian-1.5.dfsg+1.5.0. 2-2 Firefox/1.5.0.2
[2] <URL:http://pointedears.de/scripts/test/dom/cookie-frameset>
(You will observe that the frameset does not matter.)
[3] <URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:www.safalr a.com/special/googlegroupsrep ly/>
OK first thanks for taking time out to help me. I "struggle" with java
script (as you can likely see). I was attempting to set a cookie, in
this example, "test" to a value of "DVT". When I click on URL[2]
above, I see that the cookie is not set:
read cookie test: null
set cookie test : undefined
read cookie test: null
Are you seeing the cookie being set to "DVT" and returning anything on
your browser?
***UPDATE*** !!!! I just tried your link using Firefox instead if IE 6
and I see it fine!
read cookie test: DVT
set cookie test : undefined
read cookie test: DVT2
I guess I have screwed up my IE browser settings somehow. Now just to
figure out what I did!!! I checked Tools, Internet Options, Privacy,
it was set to "Medium". Not sure what else I could have done?
OK first thanks for taking time out to help me. I "struggle" with java
script (as you can likely see). I was attempting to set a cookie, in
this example, "test" to a value of "DVT". When I click on URL[2]
above, I see that the cookie is not set:
read cookie test: null
set cookie test : undefined
read cookie test: null
Are you seeing the cookie being set to "DVT" and returning anything on
your browser?
***UPDATE*** !!!! I just tried your link using Firefox instead if IE 6
and I see it fine!
read cookie test: DVT
set cookie test : undefined
read cookie test: DVT2
I guess I have screwed up my IE browser settings somehow. Now just to
figure out what I did!!! I checked Tools, Internet Options, Privacy,
it was set to "Medium". Not sure what else I could have done?
On further test, I can put the same html file in the primary domain and
a copy in the URL Frame pass-to-directory domain, my IE 6 fails to see
the cookie when it is on the URL Frame and handles the cookie as
expected. My IE 6 also fails to set the cookie when I go to your
link:
<URL:http://pointedears.de/scripts/test/dom/cookie-frameset>
Using Firefox, I can see the cookie everywhere I put it, including your
example.
Don Juan wrote: On further test, I can put the same html file in the primary domain and a copy in the URL Frame pass-to-directory domain, my IE 6 fails to see the cookie when it is on the URL Frame and handles the cookie as expected.
As I said, the domain of the cookie must not be different to the domain
of the document resource that modifies or retrieves it. Since you did/do
not specify the domain, it was/is set automatically in the cookie when the
cookie is set or modified.
bar.example.com cannot retrieve a cookie set by foo.example.com , unless the
cookie was set with "domain=example .com". And a resource at example.net
cannot retrieve a cookie set by a resource at example.com (unless perhaps
the security level is set very low).
My IE 6 also fails to set the cookie when I go to your link:
<URL:http://pointedears.de/scripts/test/dom/cookie-frameset>
Using Firefox, I can see the cookie everywhere I put it, including your example.
Why, you should really have a minimum clue about browsers before you start
coding for them:
,-<news:11******* *************** @g10g2000cwb.go oglegroups.com>
|
| I guess I have screwed up my IE browser settings somehow. Now just to
| figure out what I did!!! I checked Tools, Internet Options, Privacy,
| it was set to "Medium". Not sure what else I could have done?
The "Medium" level in your IE Privacy settings simply prevent these
non-session cookies with unspecified `domain' label from being set (but
they can be read).
Change it to "Low"[1] and these cookies are set without you being asked.
Change it to "User-defined" by activating "Advanced" and "Disable Automatic
Cookie Handling" and you will be asked to set it (and can see the "Details"
of it) unless you set "Accept Always" or "Block Always". AIUI that is
because the other domain is regarded as "third-party provider", so if you
explicitly block those cookies via the "Advanced" dialog, they will never
be set as well.
Tested with IE6 SP1 on Win2k SP4 with .NET 1.1 support [Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)].
BTW, please do not amok-post like this next time:
<URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:http://www.safalra.com/special/googlegroupsrep ly/>
HTH
PointedEars
___________
[1] UI labels are estimates, translated from German
Not sure what amok-post means, sorry about whatever i did ... I merely
copied text from one part of this post to the other. Not sure how to
work the controls here? It was just a reference to text above you had
aready entered. Sorry if I caused any problem.
Here is an update. I tried the following link from 4 different
systems. ( http://pointedears.de/scripts/test/dom/cookie-frameset)
IE V5 on Windows 2000 - cookie WAS resolved
IE V6 on Windows 2000 - cookie NOT resolved
IE V6 on Windows XP (system A) - cookie NOT resolved
IE V6 on Windows XP (system B) - cookie NOT resolved
Firefox on all OS above - cookie WAS resolved
It is possible all the IE 6 systems I have are at the same fixpack
level. I am investigating that now to see if there is a fix I can
apply. I earlier thought this was isolated to my single main
development system but now I have proved it fails with 3 of my systems
that have IE 6 on them, regardless of the base OS. Firefox works with
any OS (of mine, 2K or XP, that is).
Don Juan wrote: Not sure what amok-post means, sorry about whatever i did ... I merely copied text from one part of this post to the other.
Pardon me?
Not sure how to work the controls here?
It would be best if you stopped using Google Groups for _posting_ at all.
(However, I am not sure if you are capable of using the controls of a
newsreader if you cannot even use Google Groups properly.)
It was just a reference to text above you had aready entered. Sorry if I caused any problem.
As if posting a followup to a posting of yourself was not bad enough,
you did not quote anything of what you are referring to, although there
are enough pointers in the newsgroup and in the FAQ already that not only
tell otherwise but also tell how to do it right. And you did it wrong
_again_, although I provided those pointers in my very posting you have
replied to. Again :-(
Here is an update. I tried the following link from 4 different systems. (http://pointedears.de/scripts/test/dom/cookie-frameset)
IE V5 on Windows 2000 - cookie WAS resolved IE V6 on Windows 2000 - cookie NOT resolved IE V6 on Windows XP (system A) - cookie NOT resolved IE V6 on Windows XP (system B) - cookie NOT resolved
That is completely useless information because the browser is not the
problem! The browser privacy features and their settings are.
Firefox on all OS above - cookie WAS resolved
It is possible all the IE 6 systems I have are at the same fixpack level. I am investigating that now to see if there is a fix I can apply. I earlier thought this was isolated to my single main development system but now I have proved it fails with 3 of my systems that have IE 6 on them, regardless of the base OS. Firefox works with any OS (of mine, 2K or XP, that is).
You have still not understood (have you even read my posting?). You have to
check the _privacy settings_ in each browser. Probably they are different
by default (maybe influenced by the security fixes), or the feature works
different. It is _not_ a script problem; setting/modifying cookies is not
restricted to scripting. So you are _off topic_ here.
Score adjusted
PointedEars
--
The German psychs, the German authorities, the German secret service agents
are [...] fanatics, they are insane and known of persecuting innocent people
and Scientologists. -- "The only real Barbara Schwarz", dsw.scientology ,
<16************ **************@ posting.google. com> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Meehan |
last post by:
I created a music website that allows people to sign up and post
messages on some message boards and update their profiles and such.
The login script uses cookies, so when they Log Into the site it does
something like:
Response.cookies("ID") = RS.fields("UserID").value
Response.cookies("USERNAME") = RS.fields("Username").value
Response.cookies("LEVEL") = RS.fields("ULevel").value
and from there, I have a header include that will...
|
by: Marcin Gorzynski |
last post by:
Hi
Our partner is using our page in a frame. That couses a problem because our
domain is unable to issue the cookie also session does not work. each time
you click in the frame new session is created.
Is there any way that cookie can be issed , some way to go arround frames
restrictions.
Thanks for your help.
Marcin Gorzynski marcin@apartmentsapart.com
|
by: Bert |
last post by:
I have been reading the post and the FAQ and have been unable to find
anything that will help with my problem.
First let me say that I am not a web developer, designer and no next to
nothing about javascript. I am just rebuilding my site and need help. We run
a bamboo nursery and the site has listings of over 100 varieties we sell.
The site uses regular pages and framesets for the discriptions of the
bamboo. The framesets have a top...
|
by: Eric Petzold |
last post by:
What's the trick to sharing cookies between frames? I can set and read a
cookie in the same frame, but if I try to read the cookie in another frame
it is undefined. :o(
There are some other cookies that are available in all frames, so I know
that the frames are capable of reading cookies, just not the ones that I set
in the other frame.
P.S. I am not setting any expiration, path, or domain... keeping the
defaults.
|
by: Anita C |
last post by:
Hi,
How cookies can be used to set and then determine the last page visited by a
person browsing a particular website ? Also the page last visited is loaded
in an iframe, so the page last visited inside a particular iframe is what
really needs to be determined. So when the application starts up the next
time, if the last page visited was admin.aspx inside frame IContent, then
show admin.aspx in Icontent or else show home.aspx. A code...
| |
by: john.lehmann |
last post by:
Attacked is a piece of code which first hits the login page
successfully and receives back login cookies. But then when I attempt
to hit a page which is restricted to logged in users only, I fail.
That seems to be because I am not successfully re-attaching the cookies
to the header portion of the this request. I have tried 2 methods
which should both work I think. The first was to use install_opener to
attach the cookie handler back...
|
by: amitprasad.one |
last post by:
Hi-
This is Amit from Pune.
A link in an Upper Frame, targetted to open in the bottom frame as a
New Web site that is it is a new web site, doesn't do so.
Cookies are not enabled and hence the Web page does not open in the
body of the page which is another frame.
|
by: rolf.matreskova |
last post by:
Hi, should cookies work when referring to an 'external' site in a
frame?
Here is the situation: http://mysite.com/page1.html contains a frame
to http://othersite.com/otherpage1.html. When I navigate in the frame
from otherpage1.html to http://othersite.com/otherpage2.html the server
returns a cookie for the browser to set. But it appears that the
cookie is not sent back to othersite.com when navigating from
otherpage2.html.
|
by: insomniac |
last post by:
Hello,
I'm not a newbie to cookies, however I am stumpped by a receent issue
that has come up. I am running my web application through a frame
that belongs to another company. This application is much like an
Ariba Punhout application.
I am persisting cookies when the user first enters our application
within the frame, however when I redirect to another page, the cookies
are gone. I have tried setting the domain on the cookie and...
|
by: parkpost |
last post by:
Hi - I'm making a comparison site with frame and have encountered a problem. Pages come up in a lower frame that I want to interact with, but I keep getting a message from them saying "enable cookies on your browser to continue." Cookies are enabled on my browser so I am assuming that frames are preventing the cookies from working. I need a script that will instruct my framing page to receive the cookies of my framed page, so that we can...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |