Unanswered: Problem with sessions on cookies disabled browsers
I am doing a site where I store a temporary customer ID in cookie and then pass it to a session, this is working fine on browsers with cookies enabled, however it is not if cookies are blocked, here is the logic I used:
-1. detect if there is a session variable with a customer ID
-If there is a session then this is not the first page viewed by the user and there is nothing to do but to leave the session as it is
-If there is no session, check to see if there is a cookie with the customer ID, if there is, it is a returning customer, place the customer id stored in the cookie in the session variable for this visit
-If there isn't it is a first time visitor, place a cookie with the temporary customer id for future visits and place the same customer id in a session for the time being.
The way I have done it is than if a session with the customer id already exist just leave it alone, however on cookie disabled browser it reasigned a new customer ID to the session for each page and I just can't understand why?
//first we check if the user as a session open with a customer ID
//to make it easy we will create a customer id which will also be used in the cart
//the customer does not have a session open for the shopping cart
//we check if there is a cookie to see if it is an exising customer
var cookie = Request.Cookies("custId");
if (cookie!= "" && cookie!="undefined")
//there is a cookie, it is a returning customer, we set the session to the value of the cookie
Session("custId") = cookie;
//no cookie found, we create a new customer id and set it to both the cookie and the session
var d = new Date();
var mil = String(d.getTime());
var custId = mil;
Session("custId") = custId;
Response.Cookies("custId") = custId;
var d = new Date();
var y = d.getYear()+ 2;
var m = d.getMonth() + 1;
var day = d.getDate();
var ExDate = m +" "+ day + "," + y ;
from memory (this could be wrong it was ages ago that I learnt this stuff) when you use sessions you actually create a cookie on the clients machine by default. You need to in order to match the user to their session. The cookie contains a session id which is passed to the server to uniquely identify the user...
So, in short, sessions will not work without cookies...