Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Cookies usage problem
Fri, Dec 6 2013 11:32 AMPermanent Link

aberas

I've been trying to use the instance of TCookies intrgrated in the webcore module, but I'm not able to get it right.

I've tried

labelName:=Cookies.items['data'];

But I get no data.

If, instead, I create de object...

var
 ckData:TCookies;
begin
 ckData:=TCookies.create;
 labelName:=ckData.items['data'];

then I get the correct values.

But from what I've read, this is not the sugested way to use it.

So, what I am doing wrong?
Fri, Dec 6 2013 12:08 PMPermanent Link

Walter Matte

Tactical Business Corporation


I reported this to Tim - here is a workaround fix he sent me.  You need to add a fix (line) in WebCore.wbs see below where it is marked "<<<<<< Here,"  add the line:

CheckLoaded;


My Error report:
<< Cookies.Exist('xyz') - always returns false

but Cookies.items['xyz'] actually returns the cookie. >>

Tim's response:

Yep, here's the fix for now:

(WebCore.wbs)

function TCookies.Exists(const Name: String): Boolean; begin
  CheckLoaded;  <<<<<<<<<<<<<<<<<<<<<<<<<<<<< here
  Result:=(FItems.IndexOfName(Name) <> -1); end;


Walter


aberas wrote:

I've been trying to use the instance of TCookies intrgrated in the webcore module, but I'm not able to get it right.

I've tried

labelName:=Cookies.items['data'];

But I get no data.

If, instead, I create de object...

var
 ckData:TCookies;
begin
 ckData:=TCookies.create;
 labelName:=ckData.items['data'];

then I get the correct values.

But from what I've read, this is not the sugested way to use it.

So, what I am doing wrong?
Fri, Dec 6 2013 12:10 PMPermanent Link

Walter Matte

Tactical Business Corporation


ALSO - DO NOT CREATE COOKIES

Cookies := TCookies.Create;    *** NO NO


It is already automatically created in the framework.


Just use it - don't create it.


Cookies.Exist('xyz');


Walter
Fri, Dec 6 2013 3:11 PMPermanent Link

aberas

Thanks, but even with de modification on webcore it only works partialy: I can read a preexistent cookie, but If I create one inside a TPage in the same module, I'm unable to read its value.
With my unholy method it works Smile

Also, my I ask what is the problem in creating the cookies?

Thanks for the repllies.



Walter Matte wrote:


ALSO - DO NOT CREATE COOKIES

Cookies := TCookies.Create;    *** NO NO


It is already automatically created in the framework.


Just use it - don't create it.


Cookies.Exist('xyz');


Walter
Mon, Dec 9 2013 6:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Aberas,

<< Thanks, but even with de modification on webcore it only works partialy:
I can read a preexistent cookie, but If I create one inside a TPage in the
same module, I'm unable to read its value. >>

The upcoming 1.03 has a new Refresh method for this purpose.  EWB caches
cookies in order to avoid having to constantly parse the cookies from the
browser, and this method will cause the TCookies to re-load the cookies from
the browser:

WebCore.wbs:

  TCookies = class(TObject)
     private
        FItems: TStrings;
        FLoaded: Boolean;
        procedure CheckLoaded;
        function GetCount: Integer;
        function GetEnabled: Boolean;
        function GetItem(Index: Integer): String;
        function GetItemByName(const Name: String): String;
     public
        constructor Create; override;
        destructor Destroy; override;
        property Count: Integer read GetCount;
        property Enabled: Boolean read GetEnabled;
        property Items[Index: Integer]: String read GetItem; default;
        property Items[const Name: String]: String read GetItemByName;
default;
        function Exists(const Name: String): Boolean;
        procedure Set(const Name: String; const Value: String;
                      MaxAge: Integer=-1; const Path: String='';
                      const Domain: String=''; Secure: Boolean=False);
        procedure Clear(const Name: String; const Path: String='';
                        const Domain: String=''; Secure: Boolean=False);
        procedure Refresh;  <<<<<<<<<<<<<< New
     end;

procedure TCookies.Refresh;
begin
  FLoaded:=False;
  CheckLoaded;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Dec 10 2013 4:17 PMPermanent Link

aberas

Tim:

Thank you very, very much. It now works perfectly (or at least as I thought it should work Smile).

"Tim Young [Elevate Software]" wrote:

Aberas,

<< Thanks, but even with de modification on webcore it only works partialy:
I can read a preexistent cookie, but If I create one inside a TPage in the
same module, I'm unable to read its value. >>

The upcoming 1.03 has a new Refresh method for this purpose.  EWB caches
cookies in order to avoid having to constantly parse the cookies from the
browser, and this method will cause the TCookies to re-load the cookies from
the browser:

WebCore.wbs:

  TCookies = class(TObject)
     private
        FItems: TStrings;
        FLoaded: Boolean;
        procedure CheckLoaded;
        function GetCount: Integer;
        function GetEnabled: Boolean;
        function GetItem(Index: Integer): String;
        function GetItemByName(const Name: String): String;
     public
        constructor Create; override;
        destructor Destroy; override;
        property Count: Integer read GetCount;
        property Enabled: Boolean read GetEnabled;
        property Items[Index: Integer]: String read GetItem; default;
        property Items[const Name: String]: String read GetItemByName;
default;
        function Exists(const Name: String): Boolean;
        procedure Set(const Name: String; const Value: String;
                      MaxAge: Integer=-1; const Path: String='';
                      const Domain: String=''; Secure: Boolean=False);
        procedure Clear(const Name: String; const Path: String='';
                        const Domain: String=''; Secure: Boolean=False);
        procedure Refresh;  <<<<<<<<<<<<<< New
     end;

procedure TCookies.Refresh;
begin
  FLoaded:=False;
  CheckLoaded;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Image