473,500 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

remember me cookie in asp .net

hi,
I'm trying to remember a user who has visited the page. what i found out was
to use persistent cookie, is there any other way that i can remember the
user next time he visit?

When using cookies, I used the code below to add
-----in login.aspx------
Dim aCookie As New HttpCookie("userInfo")
aCookie.Values("userID") = "1"
aCookie.Expires = DateTime.Now.AddYears(50)
Response.Cookies.Add(aCookie)

and to retrieve, I used
-----in default.aspx------
Server.HtmlEncode(Request.Cookies("userInfo")("use rId"))

but I wasn't able to retrieve values from the cookies. does it matter where
I create the cookies, as i check for the cookie in default.aspx and redirect
to login.aspx if the cookie is not found.

Hope someone can help!

Thank You!!!
Jan 7 '06 #1
5 4726
Hi James,

One possible reason you can't retrieve cookie is that your browser blocks
cookie. Hence it never writes cookie to client computer.

HTH

Elton Wang
"James" wrote:
hi,
I'm trying to remember a user who has visited the page. what i found out was
to use persistent cookie, is there any other way that i can remember the
user next time he visit?

When using cookies, I used the code below to add
-----in login.aspx------
Dim aCookie As New HttpCookie("userInfo")
aCookie.Values("userID") = "1"
aCookie.Expires = DateTime.Now.AddYears(50)
Response.Cookies.Add(aCookie)

and to retrieve, I used
-----in default.aspx------
Server.HtmlEncode(Request.Cookies("userInfo")("use rId"))

but I wasn't able to retrieve values from the cookies. does it matter where
I create the cookies, as i check for the cookie in default.aspx and redirect
to login.aspx if the cookie is not found.

Hope someone can help!

Thank You!!!

Jan 7 '06 #2
James,
Here is some very simple cookie code as an example:

private void Page_Load(object sender, System.EventArgs e)
{
if(Request.Cookies["test"]==null)
{
HttpCookie c = new HttpCookie("test","hello") ;
c.Expires=new DateTime(2007,1,1);
Response.Cookies.Add(c);
}
Response.Write(Request.Cookies["test"].Value);
//....

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"James" wrote:
hi,
I'm trying to remember a user who has visited the page. what i found out was
to use persistent cookie, is there any other way that i can remember the
user next time he visit?

When using cookies, I used the code below to add
-----in login.aspx------
Dim aCookie As New HttpCookie("userInfo")
aCookie.Values("userID") = "1"
aCookie.Expires = DateTime.Now.AddYears(50)
Response.Cookies.Add(aCookie)

and to retrieve, I used
-----in default.aspx------
Server.HtmlEncode(Request.Cookies("userInfo")("use rId"))

but I wasn't able to retrieve values from the cookies. does it matter where
I create the cookies, as i check for the cookie in default.aspx and redirect
to login.aspx if the cookie is not found.

Hope someone can help!

Thank You!!!

Jan 8 '06 #3
IE Cookie Viewer is a good tool to find and use when debugging cookies. So
is any recent releases of Firefox or Netscape.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"James" <po*****@gmail.com> wrote in message
news:Og**************@TK2MSFTNGP11.phx.gbl...
hi,
I'm trying to remember a user who has visited the page. what i found out
was
to use persistent cookie, is there any other way that i can remember the
user next time he visit?

When using cookies, I used the code below to add
-----in login.aspx------
Dim aCookie As New HttpCookie("userInfo")
aCookie.Values("userID") = "1"
aCookie.Expires = DateTime.Now.AddYears(50)
Response.Cookies.Add(aCookie)

and to retrieve, I used
-----in default.aspx------
Server.HtmlEncode(Request.Cookies("userInfo")("use rId"))

but I wasn't able to retrieve values from the cookies. does it matter
where
I create the cookies, as i check for the cookie in default.aspx and
redirect
to login.aspx if the cookie is not found.

Hope someone can help!

Thank You!!!

Jan 8 '06 #4
Hi,

Thanks for your replies!
I did a check, had my browser to allowed cookies, the cookie was created
thou, but using IE Cookie Viewer recommended by Clinton, the value UserID =
1 was stored when I first access my page, but when I access it the second
time, the cookie exists but the value disappeared!

Is there other possibilities, or any mistake that I could have made?

Thank you! Hope to hear from you soon!
Jan 8 '06 #5
hi poopy,

this may help

http://msdn2.microsoft.com/en-us/lib...et.cookie.aspx

"James" <po*****@gmail.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Thanks for your replies!
I did a check, had my browser to allowed cookies, the cookie was created thou, but using IE Cookie Viewer recommended by Clinton,
the value UserID = 1 was stored when I first access my page, but when I access it the second time, the cookie exists but the value
disappeared!

Is there other possibilities, or any mistake that I could have made?

Thank you! Hope to hear from you soon!

Jan 8 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7629
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not...
13
2700
by: Kai Grossjohann | last post by:
I have a web app which comprises different frames: a menu bar frame, a search form frame, a result list frame. Depending on the state, only a subset of these frames is available. (Eg, after...
3
5277
by: TCORDON | last post by:
Can someone give me a sample or point me in the direction of one, on how to implement User "Remember Me" option when logging into a website? TIA
1
1757
by: | last post by:
I'm currently at the Macromedia Max Developer Conference in California and was impressed by vendor's InterAct User Authentication system which bascially allows one to smash together a 'Remember Me'...
9
5288
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
3
1565
by: Brian Henry | last post by:
I want to make a login form, but have a checkbox with a "remember user name" option to create a cookie on their system to save their user name and place it into the username text box when they...
4
3594
by: pek | last post by:
Any ideas on how to create a remember me option in a login box..?
4
1881
by: Samuel Shulman | last post by:
Hi How can I implement a feature of 'Remember me on this computer' I believe using cookies that next time when the user comes to the login page I can add the Userename to the appropriate Textbox...
1
2325
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hello The site I am working on redirects the user to a "session timed out" page when: - the user's session has expired AND - the user action results in a postback to the server I then...
0
7152
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7022
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6915
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5504
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4930
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3114
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3113
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.