Getting and Setting Cookies

Can anyone provide two scripts for getting and setting cookies.  The cookie name is "synkfba" and it will contain username and password.

If need to check to see if the cookie exists and if not create it.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you will need to set separate cookies for user and password:

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub SubmitBtnWrite_Click(Sender As Object, E As EventArgs)
        Response.Cookies("synkfba").Expires = "5/1/2013"
        Response.Cookies("synkfba").Value = _
        Response.Cookies("synkfba-password").Expires = "5/1/2013"
        Response.Cookies("synkfba-password").Value = _
End Sub
Sub SubmitBtnRead_Click(Sender As Object, E As EventArgs)
    Dim I as integer
    For I = 0 to Request.Cookies.Count - 1
        lblMessage1.Text = lblMessage1.Text  _
            & Request.Cookies.Item(I).Name & ": " _
            & Request.Cookies.Item(I).Value & "<BR>"
End Sub
<TITLE>Cookies Sample Page</TITLE>
<form runat="server">
<Font Face="Tahoma">
    text="Write Cookies to Browser"
    text="Read Cookies from Browser"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
It is considered very insecure and bad practice to store usernames and passwords in cookies because that makes them available to anyone who uses that computer.  Cookies stored on the computer are just text files that can be easily read.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.