473,785 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

controlling access to parts of a site

I have been trying to control access to some pages on my website for some
time without success. I have tried copying the code found on the web:

I created a page (loginform.asp) with the following form:

<form action=loginhan dler.asp method=post>
Username: <input type=text name='username' ><BR>
Password: <input type=password name='password' ><BR>
<input type=submit Value='Log In'><BR>
</form>
I then created a page (loginhandler.a sp) to handle this:

<%
u = lcase(request.f orm("username") )
p = lcase(request.f orm("password") )

'---------------------------------------------------------
'-- check to see that the form was completely filled out--
'---------------------------------------------------------
if u="" or p="" then
response.redire ct("loginform.a sp")
end if

if u<>"myusername " or p<>"mypassword " then

'access denied
response.redire ct ("loginform.asp ")
else

' let them in!
session("login" )=true
response.redire ct ("hiThere.as p")
end if
%>

I then put the following code at the top of pages I want to be secure:

<%
if not session("login" ) then
response.redire ct("loginform.a sp")
end if
%>

Everything worked well until I did the last stage. Now whether I am logged
on or not I am redirected back to my loginform.asp page.

I am using PWS with Windows 98 to test the page locally.

Can anyone suggest where I am going wrong?

Geoff Wickens

Jul 19 '05 #1
2 1795
The 1st thing to do in such cases, is response.write something so you can
get a handle on whats really happening as opposed to what you think is
happening

so I would change your
response.redire ct("loginform.a sp")
to be
response.write "[" & session("login" ) & "]

and see what you getting

session variables are always passed as text, so you may need to cast the
session var prior to using the NOT

I usually tend to test as follows
if session("varaib le") <> "" then
or
if session("varaib le") = "something specifc" then
"Geoff Wickens" <gw******@hotma il.com> wrote in message
news:ix******** ******@newsfep1-gui.server.ntli .net...
I have been trying to control access to some pages on my website for some
time without success. I have tried copying the code found on the web:

I created a page (loginform.asp) with the following form:

<form action=loginhan dler.asp method=post>
Username: <input type=text name='username' ><BR>
Password: <input type=password name='password' ><BR>
<input type=submit Value='Log In'><BR>
</form>
I then created a page (loginhandler.a sp) to handle this:

<%
u = lcase(request.f orm("username") )
p = lcase(request.f orm("password") )

'---------------------------------------------------------
'-- check to see that the form was completely filled out--
'---------------------------------------------------------
if u="" or p="" then
response.redire ct("loginform.a sp")
end if

if u<>"myusername " or p<>"mypassword " then

'access denied
response.redire ct ("loginform.asp ")
else

' let them in!
session("login" )=true
response.redire ct ("hiThere.as p")
end if
%>

I then put the following code at the top of pages I want to be secure:

<%
if not session("login" ) then
response.redire ct("loginform.a sp")
end if
%>

Everything worked well until I did the last stage. Now whether I am logged
on or not I am redirected back to my loginform.asp page.

I am using PWS with Windows 98 to test the page locally.

Can anyone suggest where I am going wrong?

Geoff Wickens

Jul 19 '05 #2
Geoff Wickens wrote:
I have been trying to control access to some pages on my website for
some time without success. I have tried copying the code found on the
web:

I created a page (loginform.asp) with the following form:

<form action=loginhan dler.asp method=post>
Username: <input type=text name='username' ><BR>
Password: <input type=password name='password' ><BR>
<input type=submit Value='Log In'><BR>
</form>
I then created a page (loginhandler.a sp) to handle this:

<%
u = lcase(request.f orm("username") )
p = lcase(request.f orm("password") )

'---------------------------------------------------------
'-- check to see that the form was completely filled out--
'---------------------------------------------------------
if u="" or p="" then
response.redire ct("loginform.a sp")
end if

if u<>"myusername " or p<>"mypassword " then

'access denied
response.redire ct ("loginform.asp ")
else

' let them in!
session("login" )=true
response.redire ct ("hiThere.as p")
end if
%>

I then put the following code at the top of pages I want to be secure:

<%
if not session("login" ) then
response.redire ct("loginform.a sp")
end if
%>

Everything worked well until I did the last stage. Now whether I am
logged on or not I am redirected back to my loginform.asp page.

I am using PWS with Windows 98 to test the page locally.

Can anyone suggest where I am going wrong?

Geoff Wickens


You didn't set the session variable a value in all cases:
If u<>"myusername " or p<>"mypassword " then
'access denied
set Session("login" ) = False
response.redire ct ("loginform.asp ")
Else
' let them in!
Set Session("login" ) = True
Response.Redire ct ("hiThere.as p")
End if

And in each of your secured pages you must Cast the session value as a boole
an:
If Not CBool(Session(" login")) Then
Response.Redire ct("loginform.a sp")
End If

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1515
by: Seda Ozulku | last post by:
I don't have much information about .Net. May be it must be a silly question. I have Windows Application running at the server. I need to Access the program functions ( like at given time program sends mail to customer or you can manually select customer and send it ) from web. Why web? I dont want to install client applications to the all user... And Clients dont have access to server via Terminal and because of th e the Server...
0
1128
by: RWC | last post by:
Hi! I'm having some trouble controlling how the XP Packaging Wizard installs my applications. In 97, there were options to replace older, never or always, if there was a file conflict. Now with XP, the user is prompted if they want to keep the file or not. I'd like to bypass this prompt and over write certain files, and NEVER overwrite others (the data file for instance). Right now, the user can choose to run the upgrade set up, but...
3
4283
by: ARobi | last post by:
I have developped an Access database with a lot of coding. The size of the database without data is about 5 meg. I am ready to copy the database to a client PC which already has a legal version of Access installed. 1.I am used to work with software such has C++ which basically save the program in many files but I notice that Access VBA save all data into a one big file. Any way I can brake it in multiple files? 2. If I make a change in...
3
3495
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no site that has this prohibition, and I have uploaded DAPs to various sites and used them from those sites. I do not understand why any site manager would prohibit DAPs. To the best of my knowledge DAPs, as HTM files, are merely hosted on the...
8
2185
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
7
5328
by: unacoder | last post by:
Is it possible to request the user's permission to be able to control IE or FireFox windows that are pointed to domains other than the base domain the script is running from? For example, if my page launches a new window pointing to a web site originating from a different domain, is it possible for my script to request and gain access to the content of that window, and be able to control the window?
17
4418
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting there, but is there a way they can find out if that application was put there from a CD or email or created at work? Hint: It's not on a client/server database, just native jet database mdb created on Access 2003 (default 2000)...
11
1674
by: Pietro Cerutti | last post by:
Hi group, here I come with a question which is quite simple per se, but for which I can't find an answer. Does the C standard guarantee that inside an expression such as (x && y) "y" is not evaluated if "x" evaluates to 0?
1
1558
by: Handle | last post by:
I want to customize some aspx / ascx files of a precompiled site (the project portofolio web access site). I have no access to source code. Using Visual Studio, when I try to edit one these files in "design view", I get the following two categories of errors: 1) Some "Cannot switch views" errors, like the following: "Cannot switch views: This end tag has no matching start tag." "Cannot switch views: Validation (XHTML 1.0...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.