Pages

Saturday, August 25, 2012

SESSION DATA LOST PHP IIS SERVER

Session Data loses while making an ajax call to a file on IIS server hosting PHP. A very common issue stated on the PHP session_start page as well

http://php.net/manual/en/function.session-start.php

/***** sess1.php *****/
session_start();
$_SESSION["key1"] = "testvalue";
header("Location: sess2.php");

/***** sess2.php *****/
session_start();
echo "key1 = '".$_SESSION["key1"]."'";

PROBLEM:
All session data is lost after a header redirect from the first page on which the session is initialized. The problem is, the PHPSESSID cookie is not being sent to the browser (ANY browser, IE or Mozilla) on the initial session page with the header("Location: ...") redirect. This is unrelated to client cookie settings - the set-cookie: header just isn't sent.

SOLUTION:
I was able to remedy the problem by switching to the ISAPI DLL version. This seems to be an MS/IIS bug, NOT a PHP bug - go figure. I hope this saves you some headaches especially with your user authentication scripts!!


*same case happens if we make an ajax request to a file 

I am still looking for a way to switch to ISAPI dll version though?

Best way I could get was to use cookies in such case scenario if possible.
Things work well on Apache server though but I am still looking for a solution to this....?

Thursday, August 23, 2012

Synchronous Javascript using event dispatchers

 if(!(resp['Indiform2']===undefined))
                        $(document).bind('pdf2',function(){
                         generatepdf('individualaccountpdf','pdf2',resp);
                        });

Bind The event as per requirements and need

And then execute it when every thing is done with

 if(filename=='InvestmentAcoountAgreement')
 $(document).trigger('pdf2');

Saturday, August 4, 2012

Simple Javascript Accordion

http://www.switchonthecode.com/tutorials/javascript-and-css-tutorial-accordion-menus