Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string GetCartId(HttpContextBase context)
- {
- if (context.Session[CartSessionKey] == null)
- {
- if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
- {
- context.Session[CartSessionKey] =
- context.User.Identity.Name;
- }
- else
- {
- // Generate a new random GUID using System.Guid class
- Guid tempCartId = Guid.NewGuid();
- // Send tempCartId back to client as a cookie
- context.Session[CartSessionKey] = tempCartId.ToString();
- }
- }
- return context.Session[CartSessionKey].ToString();
- public string GetCartId(HttpContext context)
- {
- if (context.Session.GetString(CartSessionKey) == null)
- {
- if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
- {
- context.Session.SetString(CartSessionKey, context.User.Identity.Name);
- }
- else
- {
- var tempCartId = Guid.NewGuid();
- context.Session.SetString(CartSessionKey, tempCartId.ToString());
- }
- }
- return context.Session.GetString(CartSessionKey);
- }
Add Comment
Please, Sign In to add comment