I've written a javascript function that checks for a php session. When there is no session, it works okay. But when there is a session, I get an "undefined" javascript error.
This is my js in question. I call sessionCheck() in body onLoad. If there is no session, I will get my alert of "it is null"
After creating the session and receiving the error, I view source to make sure that my php executed properly, and it did. The session var I'm pulling over in this case has a value of "admin" and it shows up in getUser() correctly, but I receive no alert and instead get the " 'admin' is undefined " error.Code:function getUser() { return "<?php getSessionUser(); ?>"; } function sessionCheck() { var ssuser = eval(getUser()); if (ssuser == null) { alert('it is null'); } else { alert(ssuser); } }
Any idea what could be causing the error? Thanks for your help.Code:function getUser() { return "admin"; } function sessionCheck() { var ssuser = eval(getUser()); if (ssuser == null) { alert('it is null'); } else { alert(ssuser); } }


Reply With Quote

Bookmarks