Click here to Skip to main content
13,835,367 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Response.Cookies["backgroundcolor"].Value = "Red";
            Response.Write(Request.Cookies["backgroundcolor"].Value);
            HttpCookie mycookie = new HttpCookie("cookie1");
            mycookie.Value = "some cookie value";
            mycookie.Expires = DateTime.Now.AddDays(100);
            Response.Cookies.Add(mycookie);
            Response.Cookies["mycookiename"].Value= "mycookievalue";
            Response.Cookies["mycookiename"].Expires = DateTime.Now.AddMinutes(15);
            Response.Cookies["visitordata"]["firstname"] = "select login from registerform where registerform.id='" + Id + "'";
            Response.Cookies["visitordata"]["lastvisit"] = DateTime.Now.ToString();
            if (Request.Cookies["mycookiename"] != null)
               mycookievalue = Request.Cookies["mycookiename"].Value;
pls check wat mistk in tis code
Posted
Updated 4-Jun-10 21:00pm
v2
Comments
Smithers-Jones 4-Jun-10 8:20am
   
Reason for my vote of 1
No. This site is not a free code-correction-service. If you have a proper question, then ask, but don't post requests for correction in this demanding tone!
Henry Minute 4-Jun-10 8:31am
   
Reason for my vote of 1
insufficient information for a proper question
Sandeep Mewara 4-Jun-10 8:44am
   
Reason for my vote of 1
Same goes here as the earlier one! too demanding!... you need to learn how to ask for help first and then post your queries.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

mehalanandu wrote:
correct this code




// Possible chance of null reference error. You should make a null check
Response.Cookies["backgroundcolor"].Value = "Red";
Response.Write(Request.Cookies["backgroundcolor"].Value);


HttpCookie mycookie = new HttpCookie("cookie1");
mycookie.Value = "some cookie value";


//100 days is too much for a cookie to expire
mycookie.Expires = DateTime.Now.AddDays(100);
Response.Cookies.Add(mycookie);


//Possible chance of null reference error
Response.Cookies["mycookiename"].Value = "mycookievalue";
Response.Cookies["mycookiename"].Expires = DateTime.Now.AddMinutes(15);


//This is not correct. Load the firstname from database, you are
// storing the query itself. ASP.NET
//is not going to execute this query for you.
//Sql Injection prone, use parameterized query
// Variable "Id" is not defined, from where this Id is coming??
Response.Cookies["visitordata"]["firstname"] =
  "select login from registerform where registerform.id='" + Id
 + "'";


Response.Cookies["visitordata"]["lastvisit"] = DateTime.Now.ToString();
if (Request.Cookies["mycookiename"] != null)


 //mycookievalue is undefined, you should create a string variable for this
 mycookievalue = Request.Cookies["mycookiename"].Value;
   
v2
Comments
mehalanandu 7-Jun-10 3:15am
   
thank u ...

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190114.1 | Last Updated 5 Jun 2010
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100