Solved

webbroker, using cookies to verify page requests

Posted on 2002-04-11
4
492 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
ID: 6935997
listening
0
 

Author Comment

by:NeilLewis
ID: 6936042
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
ID: 7184050
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
ID: 9003177
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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