From Multi Theft Auto: Wiki
Revision as of 04:06, 18 February 2013 by Jaysds1 (talk | contribs) (Example)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This function sets the value for the specified HTTP cookie of the current HTML page.


bool httpSetResponseCookie ( string cookieName, string cookieValue )

Required Arguments

  • cookieName: the HTTP cookie whose value is being set.
  • cookieValue: the new value for the specified cookie.


Returns true if the cookie value was set successfully, false otherwise.


This example is going to get the current users account name and save their name to a cookie.

<* local accName = getAccountName(user)
     if not accName then return end
     httpSetResponseCookie("userName",accName) *>
<!DOCTYPE html>
     <body onLoad="getAcc();">
          Your Account Name is: <span id="accnam"></span>
          //getCookie function from
          function getCookie(c_name){
               var i,x,y,ARRcookies=document.cookie.split(";");
               for (i=0;i<ARRcookies.length;i++){
                    if (x==c_name)
                         return unescape(y);

          function getAcc(){
               var acc = document.getElementById("accnam");
               var name = getCookie("userName");
               if(!name || name!="")
                    acc.innerHTML = name;
                    acc.innerHTML = "Could not get your account name!";

See Also

These functions can only be used from within lua blocks in HTML pages hosted by the server