Solved

IE and Ajax cookies

Posted on 2014-10-22
11
302 Views
Last Modified: 2014-11-01
I'm running into a problem with IE, not sending PHP session cookies in its AJAX calls within an iframe within the same site.

To elaborate:

I have a web application, running via https, where most of the application takes place within an iframe.

When IE users log in, the code sends a PHP session cookie.  Then, whenever I do an AJAX call within the application itself, from the iframe, the AJAX call doesn't send back the session cookie.

As I mentioned, the site is running via https, and the domain should be listed as a trusted internet zone.

I've tried having the session cookie be re-set within the iframe, and I've added a P3P privacy policy:

header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');

I've seen the problem described on these StackOverflow posts:

https://stackoverflow.com/questions/15856886/ajax-on-ie10-dont-send-cookies

https://stackoverflow.com/questions/389456/cookie-blocked-not-saved-in-iframe-in-internet-explorer

Any way I can get IE to start saving and sending back the session cookies?

BTW: I don't have any issues with Chrome, Firefox, Safari, Mobile devices, etc.
0
Comment
Question by:hdcowboyaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40398510
This is a cookie set within the parent window and not within the iframe?
What is the url for the Parent window and what is the url for iFrame window?
IE is a bit more strict about cross domain policy (and does screw up) so if there is any difference between the two urls then it won't work.
0
 

Author Comment

by:hdcowboyaz
ID: 40403339
I've tried setting the cookie in the parent and in the iframe both.

My application changes the iframe source (via javascript) whenever
people take various actions but the iframe initially loads a script that
re-sets the session cookie to have the same as the parent window.

The iframe should match the domain of the parent window, too, because I
specify it using a relative URL.

Should I manually specify the full URL in the iframe, like
https://mydomain.com/setcookie.php ?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40403347
Still didn't answer my questions...
Is the domain changing?
If you are already using ajax then why use an iframe at all, get rid of the iframe and just use ajax
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:hdcowboyaz
ID: 40403437
I'm using the iframe because that's how I'm keeping the menu from
reloading on every single page load...

The domain isn't changing, or shouldn't be, it isn't coded to anywhere...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40403486
menu from  reloading on every single page load
That's a very 80/90's mentality
0
 

Author Comment

by:hdcowboyaz
ID: 40403490
Are you dissing on me or trying to help me?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40403502
Am I dissing you - yes a bit, but not personally

Keeping a static menu that loads pages in a frame is very 90's when the average internet speed was about 28kb's and there was a (MS inspired) reason for doing it (using frames)

These days the average internet speed is at least 1Mb (myself I am on 150Mb) - loading web pages in a frame to make the website faster achieves nothing but heartache for the owner and annoyance for the user who cannot bookmark pages for example

You are already using ajax, so you are using 90's technology with 21st technology to achieve a 90's look
0
 

Author Comment

by:hdcowboyaz
ID: 40403506
So what is the answer? Or enlighten way to do it?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40404380
Just use ajax instead of the iframe
0
 

Author Comment

by:hdcowboyaz
ID: 40407126
Are you interested in a project?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40407620
Depends on the project and what's involved - I'm quite busy at the moment.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP get fieds value 2 36
HTML editor custom button 3 82
How to I read text a text box using code in another form? 9 58
allow link tag to be submit like form 15 52
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question