Solved

cookie to authenticate

Posted on 2009-04-02
1
214 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now