Solved

Cash pb!

Posted on 2000-02-27
6
416 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
ID: 2564193
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
ID: 2564721
Adjusted points to 150
0
 

Author Comment

by:mirghani
ID: 2564722
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Accepted Solution

by:
geobul earned 150 total points
ID: 2565632
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
ID: 2568700
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
ID: 2586565
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

14 Experts available now in Live!

Get 1:1 Help Now