AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones específicas de la Web / Funciones del navegador
  • Example 1: Checking whether the browser accepts the cookies
  • Example 2: Writing and reading a cookie
CookieRead (Example)
Example 1: Checking whether the browser accepts the cookies
WEBDEV - Código NavegadorPHP This example is used to check whether the current browser accepts the cookies.
// -- Button/Link with "no" server action, browser onclick event
// Checks whether the cookies are accepted by the browser
 
// Write a cookie in a browser code
sCookieVal is string
sCookieVal = DateSys() + TimeSys()
CookieWrite("TestCookieAccepted", sCookieVal)
// Re-read the cookie and check the value read
IF NOT sCookieVal = CookieRead("TestCookieAccepted") THEN
// Cookies not accepted
Error("The browser does not accept the cookies", ...
"Modify the parameters of your browser" + ...
"to accept the cookies.")
ELSE
// Cookies accepted
Info("Cookies accepted")
END
Example 2: Writing and reading a cookie
WEBDEV - Código ServidorPHPAjax The following code writes a cookie in server code to indicate the last use. At the end of the server code, when going back to the browser, the cookie will be updated in the browser of the Web user.
A single cookie can be written per server process.
The cookie can be read in another session (and only in another session).
// -- Click on a button/link (server code)
// Write a cookie in server code
CookieWrite("LastUse", DateSys() + TimeSys())
This example is used to read, in server code, the value of a cookie of a previous session.
// Read a cookie in server code
// CookieRead can only be used to
// read the cookies loaded in memory at the beginning of the session.
// Therefore, the cookies written in the current session cannot be read.
 
// The cookie must have been written during a previous session
sCookieVal is string
sCookieVal = CookieRead("LastUse")
IF NOT sCookieVal ~= "" THEN
Info("The last use is: ", sCookieVal)
END
Versión mínima requerida
  • Versión 16
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/05/2022

Señalar un error o enviar una sugerencia | Ayuda local