I need to store some data during custom checkout step. I did't by modifying IWorkContext and WebWorkContext. I use Cookies to store data when checkout step is complete, then load them when order is being confirmed. It looks like this (this is part of my code from WebWorkContext.cs):
protected Dictionary<string, string> GetParcelCookies()
{
Dictionary<string, string> parcelCookies = new Dictionary<string, string>();
foreach (var item in typeof(ParcelMachineDeliverySetting).GetProperties())
{
parcelCookies.Add(item.Name, _httpContext.Request.Cookies[item.Name].Value);
}
return parcelCookies;
}
protected void SetParcelCookie(ParcelMachineDeliverySetting parcelMachineDeliverySetting)
{
foreach (var item in parcelMachineDeliverySetting.GetType().GetProperties())
{
var cookie = new HttpCookie(item.Name);
var value = item.GetValue(parcelMachineDeliverySetting, null);
if (value != null)
{
cookie.Value = item.GetValue(parcelMachineDeliverySetting, null).ToString();
}
else
{
cookie.Value = "";
}
int cookieExpires = 24 * 365;
cookie.Expires = DateTime.Now.AddHours(cookieExpires);
if (_httpContext != null && _httpContext.Response != null)
{
_httpContext.Response.Cookies.Remove(item.Name);
_httpContext.Response.Cookies.Add(cookie);
}
}
However - I don't know if something like this is safe or not, the alternative would probably be, to save my data to the database at this point and use some "IsSaved" bit - byt which is better?
As always, thanks in advance and best regards.