Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 08-21-2006, 09:08 AM Cookies problem
Junior Talker

Posts: 2
Name: Bob
Trades: 0
Hi, I am trying to do a very basic and simple password verifier using cookies. Mozilla keeps telling me that it can't perform the redirect commands and suggests
that a possible reason is that cookies have been disabled, but they haven't been disabled, so it's something else, but it still probably has to do with cookies. Here's the code, can anybody tell me what I might be doing wrong?

Here are the pages. Login.asp takes a username and password and then submits to passwordcheck.asp

<html>
<head>
<title>Logon Form</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<FORM ACTION="passwordcheck.asp" method="post">
<table height="100%">
<tr>
<td align="center">
<h3>Login to Bowserlaw admin</h3>
<p>
Username:
<INPUT TYPE="text" NAME="User" VALUE='' size="20"></INPUT>
<br>
Password:
<INPUT TYPE="password" NAME="password" VALUE='' size="20"></INPUT><br>
<INPUT TYPE="submit" VALUE="Logon"></INPUT>
</FORM>
</center>
</body>
</html>


Here is what passwordcheck does with the submission

<%
if Request.Form("User") <> "frib" OR Request.Form("password") <> "frab" then
Response.Redirect "login.asp"
Else
'Set the validation cookie and redirect the user to the default admin page.
Response.Cookies("Bowserlaw") = "OK"
Response.Redirect "dwiadmin.asp"

End if
%>

Then, with each content page, I #include password.asp at the top, which checks for a set cookie before it does anything else.

<%

if Request.Cookies("Bowserlaw") <> "OK" then
Response.Redirect "login.asp"
End if
%>

Pretty simple right? So why doesn't it work? Thanks in advance.

Last edited by blip; 08-21-2006 at 09:11 AM..
blip is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-21-2006, 12:22 PM Re: Cookies problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it's probably this logic
Code:
if Request.Form("User") <> "frib" OR Request.Form("password") <> "frab" then
it is much better to do a two stage check
Code:
if request.form("user") <> Valid_username then 
   'kick them out
else
   if request.form("password") <> Valid_Password then
     'kick them out here as well
    else
      'process the cookie/session
    end if
end if
some example code at Programming Articles - Code - ASP - Site Logon
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 08-21-2006 at 12:23 PM.. Reason: messed up the code tags
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-21-2006, 12:28 PM Re: Cookies problem
Junior Talker

Posts: 2
Name: Bob
Trades: 0
I don't understand why splitting the if statement up would change anything. The statement says if either one are incorrect, redirect them to the login page. I don't get it. Sorry if I am being dense.
blip is offline
Reply With Quote
View Public Profile
 
Old 08-23-2006, 05:25 PM Re: Cookies problem
yoemanspiffy's Avatar
Experienced Talker

Posts: 42
Trades: 0
Other than allowing you to trap what the error was, there is no difference, and it has no effect on the setting of the cookie.

I copied this onto my server and got it to work on IE/Firefox/Mozilla, etc.

The code is clean amigo.

YM
__________________
My grandfather used to work for your grandfather. Of course the rates have gone up.


Please login or register to view this content. Registration is FREE

Last edited by yoemanspiffy; 08-23-2006 at 05:34 PM..
yoemanspiffy is offline
Reply With Quote
View Public Profile Visit yoemanspiffy's homepage!
 
Old 08-24-2006, 07:49 AM Re: Cookies problem
saadatshah's Avatar
Extreme Talker

Posts: 215
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Trades: 0
Code looks fine to me
__________________
- -- --- ---- ----- ------ ------- ---------------
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Reply     « Reply to Cookies problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39945 seconds with 12 queries