Извините что поднимаю столь давнюю тему.
Нужна помощь.
прога логинится позитивно на форум PhpBB, но при переходе на страницу с добавлением поста теряются куки и сессия обрывается

Подскажите как правильно передать куки, если они изменяются постоянно.
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, ExtCtrls, OleCtrls, SHDocVw, IdCookieManager;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
IdHTTP1: TIdHTTP;
Edit3: TEdit;
Label5: TLabel;
Memo1: TMemo;
Memo2: TMemo;
IdCookieManager1: TIdCookieManager;
function Pars(T_, ForS, _T: string): string;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var StrPage, ssylka, PostPage, Token:string;
Data:TstringList;
CookMan: TidCookieManager;
begin
CookMan:=TidCookieManager.Create(IdHTTP1);
IdHTTP1.CookieManager := CookMan;
IdHTTP1.AllowCookies := True;
idhttp1.HandleRedirects:=true;
StrPage:=idhttp1.Get('http://phpbb.pl/ucp.php?mode=login');
ssylka:=(Pars('name="sid" value="',StrPage,'"'));
Data:=TstringList.Create;
Data.Add('username='+Edit1.Text);
Data.Add('password='+Edit2.Text);
Data.Add('sid='+ssylka);
Data.Add('redirect=index.php');
Data.Add('login=Вход');
Memo2.Lines.Text:=idhttp1.Post('http://phpbb.pl/ucp.php?mode=login', Data);
{post}
//здесь пытался куки настроить
IdHTTP1.Request.Host := 'phpbb.pl';
IdHTTP1.Request.UserAgent:='Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13';
IdHTTP1.Request.Connection := 'Keep-Alive';
idHTTP1.Request.ContentType:= 'text/html';
IdHTTP1.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
IdHTTP1.Request.AcceptLanguage:='ru,en-us;q=0.7,en;q=0.3';
IdHTTP1.Request.AcceptCharSet:='windows-1251,utf-8;q=0.7,*;q=0.7';
IdHTTP1.Request.Referer:= 'http://phpbb.pl/posting.php?mode=post&f=2';
IdHTTP1.Request.CustomHeaders.Text:= 'Cookies: style_cookie=null; phpbb3_j7sby_u=2; phpbb3_j7sby_k=; phpbb3_j7sby_sid='+ssylka;
PostPage:=idhttp1.Get('http://phpbb.pl/posting.php?mode=post&f=2');
showmessage(idhttp1.Response.RawHeaders.CommaText);
Token:=(Pars('name="form_token" value="',PostPage,'"'));
Data:=TstringList.Create;
Data.Add('icon=0');
Data.Add('subject=vlad');
Data.Add('addbbcode20=100');
Data.Add('message=The Best!');
Data.Add('lastclick=1292355023');
Data.Add('post=Отправить');
Data.Add('attach_sig=on');
Data.Add('topic_type=0');
Data.Add('topic_time_limit=0');
Data.Add('creation_time=1292355023');
Data.Add('form_token'+Token);
Data.Add('poll_max_options=1');
Data.Add('poll_length=0');
Memo1.Lines.Text:=idhttp1.Post('http://phpbb.pl/posting.php?mode=post&f=2', Data);
{/post}
if Pos('logout', StrPage)<>0 then
Label3.Caption:=Token
else Label3.Caption:='No';
Data.Free;
end;
function TForm1.Pars(T_, ForS, _T: string): string;
var
a, b: integer;
begin
Result := '';
if (T_ = '') or (ForS = '') or (_T = '') then
Exit;
a := Pos(T_, ForS);
if a = 0 then
Exit
else
a := a + Length(T_);
ForS := Copy(ForS, a, Length(ForS) - a + 1);
b := Pos(_T, ForS);
if b > 0 then
Result := Copy(ForS, 1, b - 1);
end;
end.