Solved

Cash pb!

Posted on 2000-02-27
6
422 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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…

724 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