[Gambas-user] SetCookie/DeleteCookie
Benoît Minisini
g4mba5 at gmail.com
Mon Jan 4 16:50:18 CET 2021
Le 04/01/2021 à 16:37, Hans Lehmann a écrit :
> Hello,
>
> since my request to set a cookie from a WebPage did not find an answer
> so far, I present my source code in excerpts:
>
> The class site.class contains among others this procedure:
>
> Public Sub Set_Cookie()
>
> Dim dExpires As Date
>
> dExpires = DateAdd(Now(), gb.Minute, 30)
> Response.SetCookie("GBB", "Osterburg", "", "/", dExpires, True)
>
> End
>
> and here the content of the file site.webpage:
>
> <!DOCTYPE html>
> <html lang="de">
> <head>
>
> *<%Set_Cookie%>*
>
> <title>DB-REPORT</title>
> <meta charset="utf-8">
> <meta name="viewport" content="width=device-width,
> initial-scale=1.0, shrink-to-fit=no">
> <link rel="stylesheet" type="text/css" href="css/style.css">
> <link rel="shortcut icon" type="image/x-icon"
> href="favicon/favicon_blue.ico">
> <script src="js/time.js" charset="utf-8"></script>
> </head>
> <body onload="startTime()">
> <div class=header0>
> <h1>Aktuelle Zeit: </h1><h1 id="current_time"></h1>
> </div>
> <br>
> <% PrintDBTable() %>
> </body>
> </html>
>
>
> Unfortunately no cookie is set. Therefore the question: Where is the error?
>
> With kind regards
>
> Hans
>
As soon as your WebPage is not buffered, you cannot send HTTP headers
(like cookies) while sending the page (the headers must be sent before
the contents).
You must call SetCookie() before rendering the page, or set the Buffered
property of your WebPage to TRUE.
Regards,
--
Benoît Minisini
More information about the User
mailing list