...

View Full Version : Global Flag Variable



easypeasy
07-16-2009, 07:00 PM
Hello fellow coders,

I'm new to Javascript and PHP and stuff like that, but I have experience programming in HTML, C++, and VB.

What I'm trying to do:
I'm creating a login system and have the following requirement. When the user is logged in, I want the their account information displayed at all times at the top of every page. When the user is logged out, I want the login boxes displayed in that same spot on all pages.

My Questions:
1) How can I create a Global Flag Variable that spans across multiple pages (sessions??)
2) Next step is I need to be able to embed HTML code into an if statement that checks this Global Flag variable when the page is opened. e.g. If flag = true, then x.html should look one way, if flag = false, then x.html should look another way.

Thanks for your help!!!

easypeasy
07-16-2009, 07:01 PM
P.S. Is Javascript even the right thing to be using here??

tomws
07-16-2009, 08:44 PM
P.S. Is Javascript even the right thing to be using here??

Not really. Ideally you'd be handling this on the server side. You can "dress up" the behavior with javascript/jquery, but the core of the login testing should be on the back side.

easypeasy
07-16-2009, 09:36 PM
Tom, are you saying I should be using PHP here?

I did figure out a pretty solid way using "document.cookie" in Javascript to track the login status...

Philip M
07-16-2009, 09:42 PM
I did figure out a pretty solid way using "document.cookie" in Javascript to track the login status...

What about people who have Javascript disabled, or have configured their browser to reject cookies?

As tomws says, this should be done using server-side scripting.

tomws
07-16-2009, 09:48 PM
Agree with Philip. I'd use PHP since it's what I know. Some prefer paying for coding privileges, though, so the dotNET family works for them. :)

:o Forgot to mention Java, too.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum