Solved

Cash pb!

Posted on 2000-02-27
6
415 Views
Last Modified: 2010-04-04
My CGI App set cookies when the user log in and when log out it clear cookies the pb that after deleting cookies if i didn't Click Refresh in the browser it never delete it and i cann't ask the user in my App to click refresh button!
in brief there is a problem in cookies cashin how it can be solved.
thanks.
0
Comment
Question by:mirghani
  • 4
  • 2
6 Comments
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,

  When your app clears the cookies on logout response (sets zero or blank values) they become unusable.
  What's the problem here?

Regards, Geo
0
 

Author Comment

by:mirghani
Comment Utility
Adjusted points to 150
0
 

Author Comment

by:mirghani
Comment Utility
I delete the cookies using your method (assigning blank values to cookies fields) but still it didn't work. Moreover when I set new cookies for example when a different user login, the last user name cann't be overwritten. I use this method of assigning cookies:

Response.Cookies.Add;
Response.Cookies.Items[0].Name:= 'Login';
Response.Cookies.Items[0].Value:= Login;

another problem: when I assign expiration date to this cookies, for example after a minute, it didn't work and the cookies doesn't deleted after 1 minute it may take a day, how can I solve these problems?

Meerghani
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 17

Accepted Solution

by:
geobul earned 150 total points
Comment Utility
Hi Meerghani,

Sorry for the late reply :-(

I've tested Standalone CGI with IIS on NT4 server. The source follows:
--------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, HTTPApp;

type
  TWebModule1 = class(TWebModule)
    procedure WebModule1WebActionItem1Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
    procedure WebModule1WebActionItem2Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
    procedure WebModule1WebActionItem3Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  WebModule1: TWebModule1;

implementation

{$R *.DFM}

{ login action }
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  slCookies : TStringList;
  login, passw : string;
begin
  slCookies := TStringList.Create;
  login:=Request.ContentFields.Values['login'];
  passw:=Request.ContentFields.Values['passw'];

  Response.cookies.Add;
  Response.cookies.items[0].name:='login';
  Response.cookies.items[0].value:=login;

  Response.cookies.Add;
  Response.cookies.items[1].name:='passw';
  Response.cookies.items[1].value:=passw;
{ slCookies.Add('login='+login);
  slCookies.Add('passw='+passw);
  Response.SetCookieField(slCookies,'','',Request.Date,False);
}  Response.Content := '<HTML><HEAD><TITLE>On Login</TITLE></HEAD><BODY><FORM METHOD=POST ACTION="/scripts/test.exe/logout">'+
     'Just set !!!'+
     'User     : '+Response.Cookies.Items[0].HeaderValue+
     'Password : '+Response.Cookies.Items[1].HeaderValue+'<BR>'+
     '<INPUT TYPE=submit NAME="Logout" VALUE="Logout"></FORM></BODY></HTML>';
  Response.SendResponse;
  Handled := True;
  slCookies.Free;
end;

{ logout action }
procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  slCookies : TStringList;
  login, passw : String;
begin
  login := Request.CookieFields.Values['login'];
  passw := Request.CookieFields.Values['passw'];
  Response.Content := '<HTML><HEAD><TITLE>On logout</TITLE></HEAD><BODY><FORM METHOD=POST ACTION="/scripts/test.exe/last">'+
     'Cookies are still here !!!'+
     'User     : '+ login+
     'Password : '+ passw+'<BR>'+
     '<INPUT TYPE=submit NAME="OKBtn" VALUE="Last"></FORM></BODY></HTML>';
  { Clear cookies }
  slCookies := TStringList.Create;
  Response.cookies.Add;
  Response.cookies.items[0].name:='login';
  Response.cookies.items[0].value:='';

  Response.cookies.Add;
  Response.cookies.items[1].name:='passw';
  Response.cookies.items[1].value:='';
{  slCookies.Add('login='+'');
  slCookies.Add('passw='+'');
  Response.SetCookieField(slCookies,'','',Request.Date,False);
}  Response.SendResponse;
  Handled := True;
  slCookies.Free;
end;

{ last action }
procedure TWebModule1.WebModule1WebActionItem3Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  slCookies : TStringList;
  login,passw : String;
begin
  slCookies := TStringList.Create;
  login := Request.CookieFields.Values['login'];
  passw := Request.CookieFields.Values['passw'];
  Response.Content := '<HTML><HEAD><TITLE>Outside login-logout</TITLE></HEAD><BODY>'+#10+
     'Cookies are empty!!!'+
     'User     : '+ Request.CookieFields.Values['login']+
     'Password : '+ Request.CookieFields.Values['passw']+
     '</BODY></HTML>';
  Response.SendResponse;
  Handled := True;
  slCookies.Free;
end;

end.
------------------------
There are three actions : /login, /logout and /last and no default action. The script is placed in /scripts directory. Login and passw are entered in an external page wich has :
<FORM METHOD=POST ACTION="/scripts/test.exe/login">
 
In both cases :SetCookieField or your code this program works the same way.

I'm gonna to think that there is a problem in your HTML server, not in the program!!!

Regards, Geo
0
 

Author Comment

by:mirghani
Comment Utility
hi geo ,
i tested ur App it's ok,but how can i make the Actions in Sequence,when i submit the external form i get the form with login button,pressing the login button never execute the last action.
0
 

Author Comment

by:mirghani
Comment Utility
Geo Sorry for Delay:-)
and thanks for ur help.
i hope u to co-operate with me later.
Regards Meer.a.a
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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