CGICookieValue()

Syntax

Result$ = CGICookieValue(Name$)
Description
Returns the value of the specified cookie.

Parameters

Name$ The name of the cookie to get the value. The cookie name is case-sensitive. CGICookieName() can be used to get the name of a specified cookie. To get the number of available cookie, use CountCGICookies().

Return value

Returns the value of the specified cookie.

Example

  If Not InitCGI() Or Not ReadCGI()
    End
  EndIf
  
  WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html") ; Write the headers to inform the browser of the content format
  WriteCGIHeader(#PB_CGI_HeaderSetCookie  , "mycookie=hello", #PB_CGI_LastHeader) ; Write one cookie named 'mycookie'
  
  WriteCGIString("<html><title>PureBasic - cookies</title><body>" +
                 "NbCookies: " + CountCGICookies() + "<br><br>")

  ; List the all cookies and display their name and value
  ;
  For k = 0 To CountCGICookies()-1 
    WriteCGIString(CGICookieName(k)+": " + CGICookieValue(CGICookieName(k)) + "<br>")
  Next

  WriteCGIString("</body></html>")

See Also

CountCGICookies(), CGICookieName()

Supported OS

All

<- CGICookieName() - CGI Index - CGIParameterData() ->