Internet Explorer, jQuery, session lost php - php

I have an unsual problem. I am developing an website witch is behind a load balancer. We have 4 frontends. For some reason, in Internet explorer, session is lost. We are using database session and it is working in all other browsers. After days of debugging, i eliminate the following lines from a JS file:
$('div').each(function(){
console.log($(this));
if($(this).attr('role') == 'dialog') {
$(this).addClass('callmenow_wrapper');
}
if($(this).attr('class') == 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix') {
$(this).addClass('callmenow_title');
}
if($(this).attr('class') == 'ui-dialog-buttonpane ui-widget-content ui-helper-clearfix') {
$(this).removeClass('ui-widget-content');
}
$('button').addClass('button-call-popup');
});
Now everything is working as expected. If i put back this lines in IE, the session will be lost. If anyone has experienced something wired like this, please advice.
Thank you.
PS: I read tons of documentations and similar problems. I've set P3P headers, etc. Nothing worked until i removed this lines.

Related

PHP / jQuery Ajax / Sessions Strange behaviour only on Chrome for Android

I have been struggling with a couple of strange issues in my free time project I'm workig on. It's my first "big" PHP / JS project, and to be honest I'm using ajax for the first time so I might be just missing something.
Anyways, here how it is. I'm programming a very simple invoicing system using PHP and jQuery technologies with mPDF library to generate an PDF file from HTML/CSS. I'm using mainly Session variables inside the template that gets sent to mPDF to generate an PDF invoice.
Issue I'm experiencing is on Chrome for Android, tested on latest version on OnePlus One. The Session variables are not showing in the PDF itself. I think it worked like once or twice totally at random. My friend with Android device and Google Chrome also confirms same issue.
test.php:
<?php
session_start();
error_reporting(E_ALL);
if (!isset($_SESSION['GLO_IS_LOGGED_IN'])) {
header("Location: index.php");
exit;
}
include('libs/mPDF/mpdf.php');
ob_start();
include('protected/templates/template.php');
$data = ob_get_clean();
$mpdf = new mPDF();
$mpdf->WriteHTML($data);
$mpdf->Output('protected/invoices/Faktura ' . date('j-m-Y-H-i-s') . '.pdf');
$mpdf->Output('Faktura ' . date('j-m-Y-H-i-s') . '.pdf', 'D');
unset($_SESSION['VAR_DESCRIPTION_ARRAY']);
unset($_SESSION['VAR_AMOUNT_ARRAY']);
unset($_SESSION['VAR_PRICE_ARRAY']);
unset($_SESSION['VAR_TO_ADDRESS']);
unset($_SESSION['VAR_INVOICE_NUMBER']);
Here is generateInvoice.php file that you might have noticed in the invoice-script.js:
<?php
session_start();
error_reporting(E_ALL);
if (!isset($_SESSION['GLO_IS_LOGGED_IN'])) {
header("Location: index.php");
exit;
}
if (!empty($_POST['invoice-number'])) {
$_SESSION['VAR_INVOICE_NUMBER'] = trim($_POST['invoice-number']);
} else {
echo('Please add invoice number');
exit;
}
if (!empty($_POST['to-address'])) {
$_SESSION['VAR_TO_ADDRESS'] = ($_POST['to-address']);
} else {
echo('Internal Error');
exit;
}
$_SESSION['VAR_DESCRIPTION_ARRAY'] = $_POST['invoice-description'];
$_SESSION['VAR_AMOUNT_ARRAY'] = $_POST['invoice-amount'];
$_SESSION['VAR_PRICE_ARRAY'] = $_POST['invoice-price'];
I don't want to make this post very-long so I'll stop posting any code snippets here. Believe me that I have done everything I could to find out myself what's going on and it feels really bad that I cant figure it out myself and that I need to ask others for help. Anyways thanks for any feedback and help. Cheers!
'invoice-form' doesn't contain any fields - the input tags should be within the form
Ok people, I think I have found a solution for this.
Commenting away all of the unset methods at the end in test.php solved the Chrome for Android issue.
I don't understand why this was happening in the first place. Why were the session variables unset BEFORE the invoice was generated? They shouldn't be, right? Or I am really missing something? I know I shouldn't ask for clarification in my own answer but I think at this point I really need to.
Cheers and thanks to IanMcL for solving my Edge issue!

Javascript alert quickly disappears

This may be hard to help me with but I'm out of options and have no hair left so here goes;
I have this simple part in my program where if a check box is disabled and the user is using the site on a device like an iPad they will get an alert box popup if they touch the check box. The problem that I'm having is that it works as expected on one domain but then on another domain it just flashes very quickly then goes away.
Because I don't have a Mac computer I can't use the Safari Web Console installed to see if any errors are coming up.
Here's the code to generate the alert;
if ($device == 'TAB') {
echo "<div id='" . preg_replace('/[^a-zA-Z0-9]/', '', $menu_name) . "OV'
class=\"overlay\" onClick=\"alert('My message');\"></div></div>";
} else {
echo "</div>";
}
Any ideas of why this would work in one place and not the other and anything that I can do to try to get the iPad to give me more info to what's going on here?
Here is where it works, interactive-floor-plan dot com/ifp.php?width=633&ProductID=1
and here is where it doesn't
plangator dot com/demo/ifp.php?width=633&ProductID=1
Your code seems completely fine to me, although your echo is a little bit unclear, because it's on one line. The problem should be somewhere else on your page. Try to find out what's happening with firebug. Here's a SO post about it.
iPad firebug lite or similar
Both links on that page seem useful to me.
Good luck!

Javascript source won't load.. kind of

I am completely stumped on this one. COMPLETELY stumped.
I'm building the framework for an ad network. While prototyping, I did most my building at Kodingen. Everything worked fine over there.
I just migrated to a new host, though, and I've got this one weird problem. Weird.
Bear with me as I explain this.
The ads for my ad network are placed through a code snippet that the user places on his site. Here's the code snippet:
<script type="text/javascript">
document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333"></scr' + 'ipt>');
</script>
And, after PHP processes the request, here's the output on the ad_engine.php page:
document.write("<div class='adframe' style='min-width:250px; min-height:100px;'><a href='click.php?adid=4224&pid=333' target='_self''><img src='http://mysite.net/ads/image.png' border='0' class='adimage' style='min-width:125px; min-height:100px;' /></a><span class='adtext'><a href='click.php?adid=4224&pid=333' target='_self''>This is the ad contents right here</a></span></div>");
This method worked fine when I was developing on Kodingen. The ad appeared on any page I placed this snippet on. But, since having migrated to my new server - and not having changed anything - this method won't work.
ON THE NEW SERVER: ad_engine.php, when typed directly into the address bar, shows the ad like usual. But when it's loaded onto any other page via that first code snippet I showed you, the ad won't appear. Strangely enough, the OLD ad_engine.php file - the one on my old host - still works fine even if I load it onto a page on my new host. Follow?
Although no ad appears, I know that the ad_engine.php page, the one on my new host, I know that it IS being processed, because MySQL changes are made like they're supposed to.
I've tried to be as clear as I can in explaining this problem, if you've got any questions just let me know.
Help?
Already tested a caching problem? Maybe your new host has different cache settings?
Try adding some random number to the .php call:
document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333&x=RANDOM_NUMBER_GOES_HERE"></scr' + 'ipt>');

Browser performance question

Using an adapted version of jquery.inplace.js for some page creation and use an OBDC connection in the background php file to query for content. Everything works, BUT...
I am surprised that IE6, 7, or 8 are all pretty quick, as is chrome, but firefox seems to take quite a few seconds for exactly the same task, in this case.
This is without firebug, or lots of other add-ons enabled. I am puzzled by what to look for.
It is a fairly simple return of some html content.
What would you try?
A cursory look at the source in the SVN doesn't show anything which I believe firefox would have problems with.
Can you explain exactly what is "slow"? Is it the POST request? Have you tried logging the HTTP Headers sent to the server from both IE and FF?
If it's the javascript itself, try running the profiler in firebug; FF might find a specific function a little "heavy" (for instance, one of the regexes).
Also, FF3.5+ already has String.trim*() methods built-in. The code you're using overwrites those with a custom version, which will be much slower and might even be causing firefox to behave oddly. Try changing the source to the following:
if( String.prototype.trim === undefined ) {
String.prototype.trim = function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
};
}
That way the plugin will only add the trim method for older browsers.

dojo crashes ie6 when using Zend Framework

I'm having issues with a application that I am writing that uses Dojo and Zend Framework. The issue only effects Internet Explorer 6, other versions of IE, ff, chrome and safari work fine with no issues.
When IE6 lands on the login page it crashes with the send details to microsoft dialog box. The login script uses dojo to provide some validation for the users to ensure that their passwords are formatted correctly etc.
I've seen on some forums that addOnLoad() function call in dojo could be the cause and a window.setTimeout() would help. http://www.dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/dom-manipulation-addonload-crashes-ie6
The problem I have is how to manipulate the dojo header that we have in the layout.phtml in the application. We currently have in the file this code in the header.
<?php
$this->dojo()->setLocalPath($this->baseUrl().'/javascript/dojo/dojo.js');
$this->dojo()->addStylesheetModule('dijit.themes.tundra');
echo $this->dojo();
?>
This produces the following in the html.
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.addOnLoad(function() {
dojo.forEach(zendDijits, function(info) {
var n = dojo.byId(info.id);
if (null != n) {
dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
}
});
dojo.parser.parse();
});
var zendDijits = [{"id":"username","params":{"regExp":"[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*#[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$","invalidMessage":"Please enter a valid email address","trim":"true","required":"true","dojoType":"dijit.form.ValidationTextBox"}},{"id":"password1","params":{"trim":"true","lowercase":"true","regExp":"^.*(?=.{6,})(?=.*\\d)(?=.*[a-zA-Z]).*$","invalidMessage":"Invalid Password. Password must be at least 6 alphanumeric characters","required":"true","dojoType":"dijit.form.ValidationTextBox"}},{"id":"submit","params":{"label":"Login","dojoType":"dijit.form.Button"}}];
How can I change this to try and add the fixes mentioned in the link, or is there another way to write this without IE6 crashing all the time?? I would prefer to fix this than remove all the client validation, just in case the client is using IE6.
thanks...
Can you reduce it down until you find what is crashing IE6? Save off your output as static html, confirm it still crashes IE and start removing code. Take that addOnLoad out altogether - does it still crash? if not, take out the forEach, and so on. Start removing elements from zendDijits array - is there one in particular that causes the trouble?
Is this a stock IE6? Any plugins/addons?
Your php there should be producing a script element to pull dojo.js. You've got soemthing wierd going on - that Zend code is known to work so we need all the information if you want to solve this.

Categories