?
Solved

Cash pb!

Posted on 2000-02-27
6
Medium Priority
?
423 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
[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
  • 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
Technology Partners: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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