29 lines
647 B
C#
29 lines
647 B
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace Front.Program.Services;
|
|
|
|
public class CookieService
|
|
{
|
|
private readonly IJSRuntime _js;
|
|
|
|
public CookieService(IJSRuntime js)
|
|
{
|
|
_js = js;
|
|
}
|
|
|
|
public async Task SetCookieAsync(string key, string value)
|
|
{
|
|
await _js.InvokeVoidAsync("setCookie", key, value, 1);
|
|
}
|
|
|
|
public async Task<string?> GetCookieAsync(string key)
|
|
{
|
|
return await _js.InvokeAsync<string>("getCookie", key);
|
|
}
|
|
|
|
public async Task DeleteCookieAsync(string key)
|
|
{
|
|
await _js.InvokeVoidAsync("deleteCookie", key);
|
|
}
|
|
} |