|
-
Jan 24th, 2001, 02:09 PM
#1
Thread Starter
New Member
I know next to nothing about JavaScript and was wondering if someone could help me out.
I have a login page to a site on our intranet that I created using code from javascript.internet.com. I was wondering how to force a visitor to perform a succesful login. In other words, If a user enters their Username and Password correctly and are sent to Page1.htm, I don't want that person to be able to bookmark Page1.htm to bypass the login page.
Thanks!
-
Jan 24th, 2001, 02:26 PM
#2
Black Cat
You need to check if the user is logged in on every page you want to secure, if they are not send them back to the login page. You have to do it server-side, not with client side Javascript. You'd use a Cookie, SessionID, or Get String to keep track of whether they are logged in.
Josh
-
Jan 24th, 2001, 02:48 PM
#3
Thread Starter
New Member
Thanks for the info Josh. Would you happen to have a link to an example or article showing a newbie how to do this?
-
Jan 24th, 2001, 03:16 PM
#4
Black Cat
What server technology are you using? For ASP try http://www.asp101.com/ or http://www.15seconds.com/
Josh
-
Jan 24th, 2001, 03:22 PM
#5
Lively Member
Here is a basic example...
Code:
<%
'**** This should be placed on the login page ****
'Create Session Variables
Session("UserID") = Request("txtUserID")
Session("Password") = Request("txtPassword")
'**** Place this on the pages you wish to secure ****
' Check to see if the user needs to be redirected to another page ==
If Session("UserID") = "" Or Session("Password") = "" Then
'== Redirect to login page ==
Response.Redirect "login.asp"
End If
%>
Dr_Evil
Senior Programmer
VS6 EE
VS.NET EA
-
Jan 24th, 2001, 04:03 PM
#6
Thread Starter
New Member
Server Tech: W2K 2000
I am sorry if I am sounding like an idiot here but I cut and pasted Dr Evil's code into a couple of test pages and when I opened the document that contained the following code:
<html>
<head>
<title>New Page</title>
<script language="JavaScript">
If Session("UserID") = "" Or Session("Password") = "" Then;
Response.Redirect "login.htm";
End If;
</Script>
</head>
<body>
<Center>It Worked!</center>
</body>
</html>
I got a Runtime error:
Line: 4
Error: Expected ';'
Which doesn't make sense to me because that is the <script language="JavaScript"> Line.
I don't really know what I am doing here so please be patient!
-
Jan 31st, 2001, 11:21 PM
#7
Junior Member
use a frame
Make your login page in a framed with a 1 pixel frame at the bottom of the frame.
I have done this on some sites and it seems to work ok.
-
Feb 1st, 2001, 04:37 AM
#8
Frenzied Member
use a frame as suggested above called 'index.html' with your login page set as the SRC
then put this in every other page
Code:
<HTML>
<HEAD>
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script language="JavaScript"><!--
if (parent.location.href == self.location.href)
window.location.href = 'index.html';
//--></script>
</HEAD>
<BODY>
</BODY>
</HTML>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|