Пример
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
Subject: Re: IdHttpServer and cookies - simple example Posted by: Will Olsen (wols…@igl.net) Date: Tue, 7 Jun 2005 Thank you for your reply. I have tried the following: procedure TServerForm.HTTPServerCommandGet(AThread: TIdPeerThread; RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo); var ReadCookie : TIdCookieRFC2109; WriteCookie : TIdCookieRFC2109; begin ReadCookie := RequestInfo.Cookies.Cookie['testcookie']; if ReadCookie = nil then begin responseinfo.ContentText := 'No Cookie'; WriteCookie := responseinfo.Cookies.Add; WriteCookie.CookieName := 'testcookie'; WriteCookie.Value := 'asfdasfdasfdasdfsdf'; WriteCookie.Domain := 'localhost'; WriteCookie.Expires := 'NEVER'; end else ResponseInfo.ContentText := 'CookieFound:' + ReadCookie.CookieText; end; whenever I run this, the server responds with "No Cookie". I am running the server locally, and I am accessing it with Internet explorer using http://localhost:8080 . Cookies are enabled in my browser. Any thoughts on what I need to change to make this work? Thank you, Will "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:42a5f41c$…@newsgroups.borland.com... > > "Will Olsen" <wols…@igl.net> wrote in message > news:42a5ee83$…@newsgroups.borland.com... > > > Does anyone have a simple example of how to get/set a > > cookie with the indy HTTP server? > > In the OnCommandGet event, the ARequestInfo and AResponseInfo parameter both > have a Cookies property, of type TIdServerCookies. TIdServerCookies has an > Add() method and a Cookie[Name] property. Have you looked at the Indy > documentation yet for details about the TIdServerCookie and TIdCookieRFC2109 > classes yet? > > Gambit Replies Re: IdHttpServer and cookies - simple example posted by Remy Lebeau (TeamB) on Tue, 7 Jun 2005 |