2

Can someone please explain what a session cookie is in .NET and how I write data into one?

Thanks,

Sachin

Sachin
  • 21
  • 1
  • [Look here](http://stackoverflow.com/questions/2589823/do-session-use-cookies) – sternr Aug 15 '11 at 11:53
  • possible duplicate of [What is the difference between a Session and a Cookie?](http://stackoverflow.com/questions/623815/what-is-the-difference-between-a-session-and-a-cookie) – Péter Török Aug 15 '11 at 12:00
  • see also [session,cookies in asp.net c#](http://stackoverflow.com/questions/4121750/session-cookies-in-asp-net-c), [Using Cookies for Web Session State - What are the pitfalls?](http://stackoverflow.com/questions/398948/using-cookies-for-web-session-state-what-are-the-pitfalls) – Péter Török Aug 15 '11 at 12:01
  • Please be aware that if you are in the European Union, there is a new directive which you should be aware of: http://www.hobo-web.co.uk/new-eu-privacy-directive-on-cookies-12-months-to-get-your-house-in-order-in-uk/ – Richard Aug 15 '11 at 12:05

3 Answers3

0

Session cookies allow users to be recognized within a website so any page changes or item or data selection you do is remembered from page to page. The most common example of this functionality is the shopping cart feature of any e-commerce site.

copied from AllAboutCookies

Amir Ismail
  • 3,865
  • 3
  • 20
  • 33
0

Session Cookies

    Webpages have no memories. A user going from page to page will be treated by the 
website as a completely new visitor. Session cookies enable the website you are visiting to 
keep track of your movement from page to page so you don't get asked for the same 
information you've already given to the site.

Session Cookies in ASP.Net

    When a user connects to an ASP.NET application, a unique session ID will be affiliated 
with the user. If nothing is put in the session however, no cookie will be sent to the 
browser. This means that the user will get a new session ID the next time a new url is open or 
the page is refreshed. If something is put on the session (HttpContext.Current.Session["Hello] 
= "hello") however, ASP.NET will issue a cookie called ASP.NET_SessionId. This cookie contains 
the user's session ID and the cookie will expire at the end of the session (when you close 
your browser).

See this for details

Haris Hasan
  • 29,856
  • 10
  • 92
  • 122
  • So, would I be right in saying that the way you write to them is by doing something like this: HttpContext.Current.Session[hello]="hello"; – Sachin Aug 15 '11 at 12:05
0

For example;

You visit http://www.blablabla.com/message.aspx and you see Please Login message.

You login the site. After that, you re-write http://www.blablabla.com/message.aspx in your browser, the automaticly redirecting your message box.

This is happening with Session Cookies.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364