tags:

views:

359

answers:

1

If cookies are disabled in the browser then how can we retain the data when user next time logs in. e.g. for login page how to retain user name is cookies are disabled?

+2  A: 

You can use cookieless sessions to store session data. This function embeds the session id in the url instead of in a cookie.

Further, you can use Asp.net Profile properties to store profile data for the user. The Profile is stored with the user and can be retrieved when the user logs on.

It is quite easy to use:

  • First you configure your profile properties in your web.config file
  • Then you set the profile properties where appropriate, for example when the user changes his settings. This is done using the static Profile class. It has members properties for all profile properties you add.
  • Finally you read out the profile properties whenever you need them by reading the properties.
  • No saving or loading is needed - this is done automagically by asp.net when a user logs on and off.

Check the MSDN library and search for Profile Properties or look here.

One thing you should note. The default profile property provider will store all profile values in one column in a table. This column contains all values stacked together to a string. In some cases this is ok, for it is an easy and efficient way to store the data, but you may want to write your own profile provider that stores the data in a more suitable manner.

Rune Grimstad