?
Solved

webbroker, using cookies to verify page requests

Posted on 2002-04-11
4
Medium Priority
?
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 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