Skip to content

Commit

Permalink
简化 Delete 方法并更新 Append 方法
Browse files Browse the repository at this point in the history
将 `Delete` 方法从块级语法改为表达式语法,使代码更加简洁。
在 `Append` 方法中添加了 `SameSite = SameSiteMode.None` 选项,以确保 cookie 的 SameSite 属性被设置为 None。
  • Loading branch information
猿人易 committed Dec 9, 2024
1 parent 30b0c1d commit 9584ad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Pek.AspNetCore/Cookies/Cookie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,13 @@ public void SetValue<T>(String name, T value, Single expireDurationInMinutes, Bo
{
Expires = DateTime.Now.AddMinutes(expireDurationInMinutes),
HttpOnly = httpOnly,
Path = path
Path = path,
SameSite = SameSiteMode.None
});
}

}
}

public void Delete(String name)
{
_httpContext?.Response.Cookies.Append(name, "", new CookieOptions { Expires = DateTime.Now.AddDays(-1d) });
}
public void Delete(String name) => _httpContext?.Response.Cookies.Append(name, "", new CookieOptions { Expires = DateTime.Now.AddDays(-1d) });
}
2 changes: 1 addition & 1 deletion Pek.AspNetCore/Pek.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pek.Common" Version="4.0.2024.1209-beta0301" />
<PackageReference Include="Pek.Common" Version="4.0.2024.1209-beta0643" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 9584ad5

Please sign in to comment.