Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Cookie ?

 Post Reply Post Reply
Author
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Topic: Cookie ?
    Posted: 21 Nov 2019 at 8:49am
Hello devs,

Is it possible to set/get cookies ?
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 21 Nov 2019 at 9:22am
Have a look at the unit WEBLib.Cookies that offers the TCookies collection for managing cookies.
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 21 Nov 2019 at 10:03am
Is there any documentation somewhere ?

And "WEBLib.Cookies" in uses give me an error at design time (but it compiles successfully).
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 9:08am
Sorry to insist, but I need this, there is no documentation, nothing else on the forum, and nothing on th web.
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 11:32am
What *exact* error do you get at design-time, as WEBLib.Cookies is unit that has the TCookies collection class and not really design-time behavior.
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 11:36am
"Cannot resolve unit name 'WEBLib.Cookies'"

I put it in global uses (at the top of the source code). 

Other WEBLib uses (Login, REST, DB,Forms,...) are OK.
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 5:06pm
You should have WEBLib.Cookies.pas in the source subfolder "Component Library Source"  of your TMS WEB Core install and this folder should be in your IDE library path. Can you double check this.
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 5:32pm
The file is in the subfolder, but I hadn't the folder in the IDE library path. I added it, but nothing changed.

However, it compiles correctly, so I can use it. My priority is to know how it works. Do you have any documentation ?
Back to Top
Feichtenschlager Thomas View Drop Down
Member
Member
Avatar

Joined: 29 Oct 2011
Posts: 73
Post Options Post Options   Quote Feichtenschlager Thomas Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2019 at 6:54pm
Hi Mathieu,

I used it this way...

uses WebLib.Cookies;
procedure TMainForm.btn_SetCookieClick(Sender: TObject);
var
  Cookies: TCookies;
begin
  Cookies := TCookies.Create;
  Try
    Cookies.Add('mycookie','789', Now + 3);
    Cookies.SetCookies;
  Finally
    Cookies.Free;
  End;
end;
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 8:54am
Thank you very much Feichtenschlager, this is exactly what I expected !

If that can help someone else, this is my code :
function PR_getCookie: string;
var
  VLOcookies: TCookies;
  VLOcookie: TCookie;
begin
  Result := '';
  VLOcookies := TCookies.Create;
  try
    VLOcookies.GetCookies;
    VLOcookie := VLOcookies.Find('name');
    if Assigned(VLOcookie) then
    begin
      Result := VLOcookie.Value;
    end;
  finally
    VLOcookies.Free;
  end;
end;

procedure PR_setCookie(p_value: string);
var
  VLOcookies: TCookies;
begin
  VLOcookies := TCookies.Create;
  try
    VLOcookies.Add('name', p_value);
    VLOcookies.SetCookies;
  finally
    VLOcookies.Free;
  end;
end;

procedure PR_deleteCookie;
var
  VLOcookies: TCookies;
begin
  VLOcookies := TCookies.Create;
  try
    VLOcookies.GetCookies;
    VLOcookies.Delete('name');
    VLOcookies.SetCookies;
  finally
    VLOcookies.Free;
  end;
end;

Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 8:58am
I still have errors at design-time. I tried to had the  "Component Library Source" in the library path called "Path", and to create a new one called "TMS" or "WEBCORE". 

The folder (and files) is stored in my local machine.

Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 8:59am
what *exact* error?
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:09am
Same as before :
"Cannot resolve unit name 'WEBLib.Cookies'"
And :
"Identifier not found 'TCookies'"
"Identifier not found 'TCookie'"
etcetera
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:16am
I cannot reproduce this:



Edited by Bruno Fierens - 26 Nov 2019 at 9:18am
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:21am
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:24am
The only reason I can see for this is that your IDE library path is not setup correct.
You can verify this yourself. Search WEBLIB.Cookies.pas in Component Library Source. You should find this file and you should make sure the path where this file is, is in your IDE library path.
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:31am
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 9:32am
Library path "PATH" has the folder deifned too.
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8601
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 10:37am
The Delphi *IDE* library path is in the IDE under Tools, Options, Delphi Options, Library 

This does NOT concern a system path!
Back to Top
Mathieu View Drop Down
New Member
New Member
Avatar

Joined: 17 Oct 2019
Posts: 36
Post Options Post Options   Quote Mathieu Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2019 at 10:47am
My bad, you're right. Thank you very much !

All is working fine now.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down