Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cash pb!

Posted on 2000-02-27
6
Medium Priority
?
425 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
geobul earned 600 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

810 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