1
I am in a virtual store project, but I have the following dilemma. A certain user accesses the store and puts a product in the cart. The purchases I am storing in a BD table, because it is easier to have a cart abandonment/withdrawal control, but the user data I am storing as follows:
if(!isset($_SESSION["SESSIONID"])){
$dataHora = date("Y-m-d H:i");
$sessionID = md5($ip.$dataHora);
$_SESSION["SESSIONID"] = $sessionID;
}else{
$sessionID = $_SESSION["SESSIONID"];
}
I set the date and time after the IP if the user is accessing from a network, such as work network, in this way if another user accesses the store through this network, will not see the purchase of the other user from another computer (correct me if I am wrong).
But what if the user closes the browser without finalizing the purchase? Upon returning, the cart will be empty. I thought about storing in Cookie, but what if the browser is not accepting Cookies? Is there any other way?
I guess that way, just by setting the date and time, you won’t be able to differentiate one machine from another in the same IP. Regarding cookies, I suggest to force the user to accept the use of cookies (check if the browser is accepting. Otherwise, send a message aiming to enable)... or use localStorage...
– Sam
Hello Dvd. Actually differentiates, because the structure is IP + Date + Time + Minute. About localStorage would not have the same functionality as the Cookie and depending on the browser would have a size limit? I confess that I never used the Torage locale.
– user24136