Solved

cookie to authenticate

Posted on 2009-04-02
1
221 Views
Last Modified: 2013-11-26
Hello Experts:

How I can use cookie to authenticate. I have to pass cookie which is receive from successful login
to all subsequent requests???

I am using VB.net in ASP.NET web application...

Regards,
CS
0
Comment
Question by:CalmSoul
1 Comment
 
LVL 5

Accepted Solution

by:
Buginator earned 500 total points
ID: 24049061
Hello CalmSoul,
I made some code for you.

When reading cookies, rememeber to always check for null (nothing), otherwise you could often end up with an error.

The following code creates a cookie with the userName of patric. The cookie expires (gets deleted) from the users browser 1 day after the creation date.
'Make cookies, when logging in
Response.Cookies("userName").Value = "patrick"
Response.Cookies("userName").Expires = DateTime.Now.AddDays(1)
 
'Later we want to check the username again
If Not Request.Cookies("userName") Is Nothing Then
    Label1.Text = Server.HtmlEncode(Request.Cookies("userName").Value)
End If

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question