Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello Developers,
I want to develop a Ecommerce Website and i am new in Web development. Please tell me, what will be unique session when a individual user visit a ecommerce website. and i got error of "Object reference not found" due to session. please tell me how i can fix this error.
Show me or send me Example for my these queries.
Posted

1 solution

Hai

what is meant by "unique session" ? if "Object reference not found" means some values is empty or cant retrieve from database or cant get value from session or anythin.....

Pls post ur code and mention which line u get error,If u ask any question try to post ur what u did,simply description cant identify error in ur project code ,so post ur code.

Try this links for session management in asp.net
https://www.google.co.in/?gfe_rd=cr&ei=HHoiU9akHozCuASb7ICoDA#q=session+management+in+asp.net[^]
 
Share this answer
 
v2
Comments
Neeraj_kaushik 13-Mar-14 23:51pm    
Sir,
When a user wants to buy a product, then what will be unique id, by which user can see only his products in Cart which he stores
Aravindba 14-Mar-14 0:11am    
Hai
For this u need to store details about userid,selected product id ,form which store id ,quantity ect in separate table "tblCart",once user purchase product u need clear this values form tblCart table or add flags like True or false in tblCart in last coloumn
Neeraj_kaushik 14-Mar-14 0:22am    
what will be userid, when user is not login in his account or if there is no process of Login.and user can buy his products direct way or without login.
Can i use UserIP address for his Userid otherwise any other best solution you have ?
Anurag Sinha V 14-Mar-14 0:39am    
even in the above case you need to provide some custom id to the user for the current session, i.e if the user closes his/her browser you need to clear the session...post some code as to what you have tried..then may be we will get a clear picture...
Neeraj_kaushik 14-Mar-14 0:45am    
I am using USer Machine Ip Address so, i create a User ip session in Global.asax file
my code is

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

HttpRequest request = base.Request;

string address = request.UserHostAddress;

string result = string.Empty;
string ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
result = ipRange[0];
}
else
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}


Session["client_ip"] = result.ToString();

}
when a user use "Add To Cart" then i also pass the "Client_IP" string for his Identification.
Please give me any other best solution and tell me how i can clear session when then use close his browser.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900