---
title: "How to get the cookie value in asp.net"  
description: "How to get the cookie value in asp.net"  
author: "marcel ethan"  
published: 2014-08-25  
updated: 2014-08-25  
canonical: https://www.mindstick.com/forum/2130/how-to-get-the-cookie-value-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How to get the cookie value in asp.net

I am creating a cookie and storing the value of [username](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username) after succesfull login. How can I [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) the cookie when the [website](https://www.mindstick.com/articles/13110/why-copywriting-is-crucial-for-new-website-build) is opened. If the cookie exist I want to fill the username [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) box from the [cookie value](https://www.mindstick.com/forum/34141/how-to-set-cookie-value-in-c-sharp). And how to decrypt the value to get the username. I am doing [server side](https://www.mindstick.com/forum/318/how-to-call-javascript-fuction-in-server-side) [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) by getting the userdetails from the database. \

I am using vs 2010 with c#

## Replies

### Reply by Sumit Kesarwani

Hi marcel, \

You may use Request.Cookies collection to read the cookies.

```
if(Request.Cookies["key"]!=null){   var
value=Request.Cookies["key"].Value;}
```


---

Original Source: https://www.mindstick.com/forum/2130/how-to-get-the-cookie-value-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
