Added code to handle session from php to js