03-07-2025, 10:50 PM
(This post was last modified: 03-07-2025, 10:52 PM by Alexandre Machado.)
(03-07-2025, 06:22 AM)Peter Home Wrote: I'm using Intraweb 16.0.4 on Delphi 10.2 (Update 3). In ServerController|CookieOptions I have the following:
CookieNameSuffix: <empty>
HttpOnly: false
RunCookieCheck: true
SameSite: ssoLax
Secure: false
SessionCookies: false
UseCookies: true
I create a cookie with this call:
WebApplication.response.Cookies.AddCookie('Username', xUser, '/', Now + 180);
I create three other cookies in the same manner.
However, upon inspection in the browser, all the cookies are created as session cookies. This is true in Firefox, Chrome and various other browsers.
How do I generate persistent cookies?
Hi Peter,
This is the code to generate 2 cookies, the first is not a session cookie, the second is a session cookie:
Code:
procedure TIWForm1.IWAppFormRender(Sender: TObject);
begin
// Persistent cookie
WebApplication.Response.Cookies.AddCookie({Name=}'NotASessionCookie',
{Value=}'NotASessionCookieValue',
{Path=}WebApplication.CookiePath,
{Expires=}Date + 1);
// Session cookie
WebApplication.Response.Cookies.AddCookie({Name=}'MySessionCookie',
{Value=}'SessionCookieValue',
{Path=}WebApplication.CookiePath,
{Expires=}0);
end;This is the result:
As you can see, it is the correct expected result.
The key here is the Expires field. When Expires = 0 is provided, the cookie is a session cookie. If Expires is less than zero, the cookie will be removed. If Expires is greater than zero, the cookie becomes a persistent cookie

