Sunday, 21 July 2013

Saving, reading and removing values from Cookies in ASP.NET MVC

This short tutorial is about how we can store any information inside the cookie and read from it.
1. Create a new cookie

HttpCookie cookie = new HttpCookie("cookieMonster");
cookie.Value = ”Hi, I am cookie monster and I am not addicted to cookies”
HttpContext.Response.Cookies.Add(cookie);

2. Read value from cookie.

string cookieValue = HttpContext.Request.Cookies["cookieMonster"].Value;

3. To remove cookie we have to use this simple trick. We will find the cookie and change expiration date to yesterday.

if (HttpContext.Request.Cookies.AllKeys.Contains("cookieMonster"))
            {
                var cookie = HttpContext.Request.Cookies["cookieMonster"];
                cookie.Expires = DateTime.Now.AddDays(-1);
                HttpContext.Response.Cookies.Add(cookie);
            }


Let me know if you find a better approach!

Adam Bielecki.

Friday, 12 July 2013

Gran Turismo 6 GT Academy Music in title before race

Short version of music inspired by Gran Turismo 6 Gt Academy.

 

I will be releasing full version soon with some guitar and keyboard solos.

Wednesday, 10 July 2013

Gran Turismo 6 Gt academy 2013, update on projects and tutorials to follow

Thank you all for sharing some of my entries regarding C# and ASP.NET MVC developing. I know how important is nowadays an access to knowledge, tutorials and open source for some busy developers.
I am working currently outside of work on project that involves google maps so I will be releasing tutorial on how to mark an location on map after typing your address and how to translate address to longitude and latitude and save those info in data base. I will also release tutorial on how to make paypal IPN to call your function in your application and store some data in database.

At the moment I am quite busy (work, some projects after work and playing Gran Turismo 6 Demo with GT Academy 2013). Currently I am on 3310th position in UK with time 23:800, I know nothing to celebrate but by judging how many players there are...

Check Alex, one of the contestant of Gt Academy edition. Amazing driving skills in real world!