Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.10.28;
Скачать: CL | DM;

Вниз

Как забросить Cookie на определенное время? Не получается   Найти похожие ветки 

 
Vlad Oshin ©   (2007-09-27 12:32) [0]

следующее должно закидывать кук, рабочий в течении expC:tdatetime; времени.

procedure SetCookie(var Response: TWebResponse; nameC,valueC:string; expC:tdatetime; run:boolean);
begin
 with (Response.Cookies.Add) do
 begin
   name := nameC;
   Value := valueC;
   Secure := False;
   Expires := expC;
   if run then Response.Cookies.WebResponse.SendResponse;
 end;
 log("SetCookie(var Response: TWebResponse; nameC,valueC:string; expC:tdatetime; run:boolean);",nameC+" "+valueC);
end;


а так беру из кука и смотрю чему равно login / pasword (тестирую)
(ShowLogPage; - предлагает перерегистрироваться)

GLOGIN:=Request.ContentFields.Values["LOGINF"];
GPASSWORD:=Request.ContentFields.Values["PASSWORDF"];
if GLOGIN<>""
 then SetCookie(Response, "LOGINF",GLOGIN, dt+ddt, false)
 else GLOGIN:=GetCookie(Request, "LOGINF");
if GLOGIN="" then response.Content:=ShowLogPage;
if GPASSWORD<>""
 then SetCookie(Response, "PASSWORDF",GPASSWORD, dt+ddt, false)
 else GPASSWORD:=GetCookie(Request, "PASSWORDF");
if GPASSWORD="" then response.Content:=ShowLogPage;

 response.Content:=VerLogin;


как считываю
Function GetCookie(Request: TWebRequest; nameC:string):string;
begin
 with (Request) do
 begin
   result:=CookieFields.Values[nameC];
 end;
 log("GetCookie(Response: TWebResponse; nameC:string):string;",result);
end;


вот в чем проблема - кук должен работать час (ddt=1час) , но работает и на след. день.


 
clickmaker ©   (2007-09-27 13:11) [1]

Response.Headers["Set-Cookie"] := Format("%s=%s; path=/; expires=%s",
 [strCookieName, strCookieValue, DateTimeToStr(IncHour(Now))]);


 
Vlad Oshin ©   (2007-09-27 13:58) [2]

Response.Headers
нет у меня такого св-ва.. (d7)

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);

Handled:=false;
тогда все работает правильно..(в моем понимании)

из хелпа
This example shows an OnAction event handler that adds a cookie to the response message. The cookie stores the current authorization information. This allows the current client to revisit the URL without resupplying a password for a limited period (1 day). Because a password is sensitive information, the cookie can only be sent on a secure connection.

procedure TWebModule1.PasswordCookieActionAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);

begin
 Handled := False; { adding a cookie does not handle the request }
 with Response.Cookies.Add do
 begin
   Name := "LastPassword";
   { Set the LastPassword cookie to the current authorization }
   { Or, if no authorization was supplied this time, carry over }
   { the authorization from the LastPassword cookie of the request }
   Value := Request.Authorization;
   if Value = "" then
     Value :=  Request.CookieFields.Values("LastPassword");

   Secure := True; { be sure to use a secure connection!!!!}
   Expires := Now + 1; { this cookie expires in one day }
 end;
end;


1.Indicates whether the request has been handled.
2.Indicates whether the incoming request has been handled.
т.е. не  был обработан..

ничего не понимаю..


 
Vlad Oshin ©   (2007-09-27 15:06) [3]

не не работает вообщето :)
короче, все неправильно

SetCookie(Response, "LOGINF",GLOGIN, dt+ddt, false)
не нужно dt, совсем

SetCookie(Response, "LOGINF",GLOGIN, ddt, false)
так работает нормально


 
Vlad Oshin ©   (2007-09-27 15:54) [4]

блинн..
нет, если я тупой - так и скажите - ты тупой

что-то вообще никакой зависимости не вижу...
он может работать минуту, может 5 минут, может 10
может через несколько секунд перезапросить логин
что ему вообще надо.. кофе со сливками или с разбегу с ноги...



Страницы: 1 вся ветка

Текущий архив: 2007.10.28;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.017 c
2-1191401258
User_0
2007-10-03 12:47
2007.10.28
Как записать путь к БД в *.ini(Interbase)


2-1191764984
alikon1
2007-10-07 17:49
2007.10.28
Изображение в БД


2-1191745609
Gringoire
2007-10-07 12:26
2007.10.28
Узнать, какая клавиша была нажата за пределами окна приложения?


4-1177402203
Malik
2007-04-24 12:10
2007.10.28
ChekedBox


4-1176882413
igornov
2007-04-18 11:46
2007.10.28
Как сделать сервис скрытым?