woodsonoversoul Posted July 9, 2009 Share Posted July 9, 2009 Hello all. I'm just getting started with session variables and have run into this problem: when I use the line <body onload="getUserInfo(" <? echo $_SESSION['username']; ?> ")"> I get <body onload="getUserInfo(" danwoods="" )=""> and I feel like I should be getting <body onload="getUserInfo(" danwoods" )"> I don't know where the equal signs or extra quotations are coming from. I use the session username variable elsewhere on the page and it works fine. Any ideas? Also, like I said, I'm a sessions newb, but, you have to start a session on every page you want to use session variables, but you only have to end the session once (ie. on logout). Is that correct? Quote Link to comment Share on other sites More sharing options...
woodsonoversoul Posted July 9, 2009 Author Share Posted July 9, 2009 Fixed it by switching up the quotes, ie: <body onload="getUserInfo(' <? echo $_SESSION['username']; ?> ')"> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 9, 2009 Share Posted July 9, 2009 danwoods="" It is likely that you have an if() conditional test in your php code that is only using a single = sign and it is changing $_SESSION['username'] rather than testing what is in it. A session is just a container that holds variables that you want to exist between page visits. If the method you are using to detect if someone is logged in is the existence of a specific session variable with a specific value, then yes unsettling that session variable or destroying the session will work to log someone out. Quote Link to comment Share on other sites More sharing options...
woodsonoversoul Posted July 9, 2009 Author Share Posted July 9, 2009 Thanks PFMaBiSmAd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.