Basic encrypted cookies.

This commit is contained in:
2021-07-30 16:28:23 -04:00
parent 93a3b140d3
commit 637170ee34
3 changed files with 73 additions and 3 deletions

View File

@ -11,7 +11,8 @@ namespace StateJobsNYSubmit.Pages
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
public int counter = 1;
private PrivateData p = new PrivateData();
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
@ -19,7 +20,15 @@ namespace StateJobsNYSubmit.Pages
public void OnGet()
{
string cookieValue = Request.Cookies["PrivateData"];
if (cookieValue != null) {
string test = p.DecryptString(cookieValue);
counter = Int32.Parse(test);
counter++;
}
Response.Cookies.Append("PrivateData", p.EncryptString($"{counter}"));
Console.WriteLine($"Value of counter: {counter}");
}
}
}