Solved

webbroker, using cookies to verify page requests

Posted on 2002-04-11
4
461 Views
Last Modified: 2010-04-04
Hi there,

I've been getting into delphi 6 webbroker and it's a lot fun. However, cookies are a little beyond me right now. I understand what they can but not how to do them.

What i've got is a user that logs in with a password and login name. The site handles orders for products so i want to make sure that the page requests being sent actually come from the person who has logged in. I've seen an example from Motaz on keeping the cookie for a period of time to remember the login details (like a "remember me" i guess). Is it along the same lines?

Cheers

Neil
0
Comment
Question by:NeilLewis
4 Comments
 
LVL 9

Expert Comment

by:ginsonic
Comment Utility
listening
0
 

Author Comment

by:NeilLewis
Comment Utility
I've been trying request.RemoteAddr and global variables instead but need to use cookies i know.

eg, in the web module create i say

strUserAddress := request.RemoteAddr;

with strUserAddress being a global variable. Then in a function ...

procedure TWebModule1.CheckIPAddress();
var
    strCompareIPAddress : string;
    textcompare : integer;
begin

strCompareIPAddress := request.RemoteAddr;
textcompare := comparestr(strCompareIPAddress, strIPAddress);

if textcompare <> 0 then //the strings don't match
begin
   response.Content := 'Address does not match';
else
  ;//do nothing (carry on)
end;


And that function is put where you want to check where the page requests are coming from. BUT I WANT TO USE COOKIES!

Neil
0
 

Accepted Solution

by:
RayNorrish earned 100 total points
Comment Utility
Your approach is wrong. You should not use request.RemoteAddr for anything critical, as this could be a proxy address, and does not indicate a unique client.

Here is the approach I use:

Have a user database table that contains at least:

User, Password, Session ID

Collect the user and password at login, and generate a session ID (some random alphanumeric).

Set the sessionID as your cookie. You must verify this session ID for all future actions of that session.

This has at least two benefits - one is that you don`t continually keep passing a usrname, password to maintain state, but a "useless" sessionID that is only valid for that session, and the other is that you should make this cookie "session only" ie. set it's expiration to 0 or -1 so that it cannot be reused.

I have written my own session management around this model, but there are several 3rd party options available.
A search for MDWeb by Mark Brittingham would be useful, and especially a visit to Shiv Kumar's tutorials (www.matlus.com) should totally enlighten you :)
0
 
LVL 1

Expert Comment

by:pnh73
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer from RayNorrish

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now