By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Looking for javascript to verify whether used logged in or not

100+
P: 365
I have Two kinds of web pagess, one is for control page for only admin login, another one is to view status for user login. initially both html files can view with 192.168.0.10/control.htm and other file is 192.168.0.10/status.htm. I searched on Internet and I got some login code. this login comes when I give 192.168.0.10, then I gets login page, I can login with admin/admin, also I can login with user/user, once login, the corresponding page comes with admin login, control.htm comesup, with user login, status.htm file shows, on both of these pages I have logout, when admin or user click on logout, then login page comes back. even admin or user logout, if I give absolute path like 192.168.0.10/control.htm or 192.168.0.10/status.htm on browsewr, those pages are comingup, how can I force without login, that page shouldnot come?. when admin or user didn't login, I don't want those pages should showup, it should show only when admin or user loggedin. These web pages running on microcontroller with limited memory, not like full pledge high-end processor, I don't have CGI/PERL on this microcontroller, I can set some variables in flash, or I can read some variables from flash to web. can I get some javascript to force login page when admin or user not logged in when they give absolute path like above, please let me know.
Oct 16 '09 #1
Share this Question
Share on Google+
12 Replies


100+
P: 365
Can some expert give me a clue about how to do this?. thanks in advance
Oct 19 '09 #2

100+
P: 365
I am new to javascript.

I have login page with javascript, checks login-id and password, admin/admin and user/user, once admin or user login, it brings control page (control.htm) for admin and status page (status.htm) for user. but without login, if I give absolute address of control page or status page directly (192.168.0.10/control.htm or 192.168.0.10/status.htm) it shows up. Is there anyway I can put a javascript validation in control/status page to makesure without login, those page shouldn't appear, can I get some javascript.

Web server running on microcontroller, not full pledge scripts like CGI/Perl won't run here.

thanks in advance
Oct 21 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
but you are aware that password validation only with Javascript is highly insecure?
Oct 21 '09 #4

100+
P: 365
Actually that is fine, by default I supply different password fof admin and user. Most of the time admin only controls, where as the users will notified that they have to login with user id only, also I am supplying different password for admin and user. Admin is the one who opens manual and reads, admin knows both passwords, where as the user don't know admin password except user password.

I added login script, I can paste if needed. What I want is, after logi, admin login takes to control page (read and write) and user login takes to status page, (Read only), but if I give absolute path, both pages are visible without either login, I need some kind of auth to show pages with abs path.

Please let me know.
Oct 21 '09 #5

100+
P: 365
cursor not pointing to login user id box, unless I keep cursor and click in that box, by default how can I force cursor goto login id box?.
Oct 21 '09 #6

100+
P: 365
It is fine if it is insecure. I am looking how inside pages shouldn't show with absolute path.
Oct 21 '09 #7

gits
Expert Mod 5K+
P: 5,390
@tvnaidu
have a look at the answer to your other post where you asked that question.

kind regards
Oct 22 '09 #8

100+
P: 365
Thanks you verymuch, appreciated.
Oct 22 '09 #9

acoder
Expert Mod 15k+
P: 16,027
I'm afraid JavaScript doesn't provide much security and it's very easy to circumvent any login process coded using JavaScript. You may try Flash.
Oct 25 '09 #10

100+
P: 365
can I get some example in Flash, I am using javascriot currently, when I go view source code, it shows complete javascript, id and password, i am looking somehow to mask that info.

Another one is, currently without login, if I give complete path like 192.168.0.10/control.htm, also 192.168.0.10/status.htm. It shows pages directly without login, Is there anyway I can add a script if user didnot login, it shouldn't show that page, can I do?
Oct 25 '09 #11

acoder
Expert Mod 15k+
P: 16,027
Not without server-side code. JavaScript can easily be seenread. Even if you obfuscate the code, it's usually a futile exercise.

I don't know about Flash. You'd have to ask in the Flash forum.
Oct 25 '09 #12

acoder
Expert Mod 15k+
P: 16,027
Noticed you have two threads on the same topic. Merged threads. Please do not double post.
Oct 25 '09 #13

Post your reply

Sign in to post your reply or Sign up for a free account.