본문 바로가기

워크

blazor Cookie

window.methods = {
    CreateCookie: function (name, value, days) {
     var expires;
     if (days) {
        var date = new Date();
         date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
          expires = "; expires=" + date.toGMTString();
     }
      else {
         expires = "";
     }
      document.cookie = name + "=" + value + expires + "; path=/";
   }    
}
@page "/"
@inject IJSRuntime JSRuntime

@code {

    private async void CreateCookie(string name, string value, int days)
       {
            var test = await JSRuntime.InvokeAsync<string>("methods.CreateCookie", name, value, days);
       }
}

'워크' 카테고리의 다른 글

Lambda Expression  (0) 2020.07.17
UserAgent 가져오기  (0) 2020.07.17
sessionStorage localStorage  (0) 2020.07.15
blazor MatTab  (0) 2020.07.13
NavigationManager 시트  (0) 2020.07.12