Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    India
    Posts
    56

    Smile Unanswered: How to create Cookies?

    Dear Friends,

    I am alive with Request.QueryString error.Here is new problem.

    I want to store login details in client browser,and I want activate the text"Logout" in the place of "Login".All my .asp pages having top level banner as "Login".If one client is Loged in, how i can store login detail in client side and then how we can change "Login" to" Logout" ,and it should be only to that particular client. I am storing that login details in database.


    Please help me in solving the problem.Need your valid suggestions


    thanX

    gmc

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Response.Cookies and Request.Cookies

    To create/update a cookie on the client's browser, all writing to the cookies must be done before anything is written to the browser. Once you've written the first "<" of the "<HTML>" tag, you're prohibited from writing to cookies.

    On the other hand, you can read from cookies at any time since their values are stored in the server's memory from the initial request of the browser.

    When your user logs in, you'd use Response.Cookies to write the value to the browser (Avoid storing personal information. Instead, store a unique identifier you can use to query the DB for more information.)

    Response.Cookies("Login")("UserID") = "Bob"

    You could simply do:

    Response.Cookies("UserID") = "Bob"

    But I like to group my cookie values together.

    With that complete, your banner would simply use the Request.Cookies("Login")("UserID") to check to see if they have been authenticated:

    If Trim(Request.Cookies("Login")("UserID")) <> "" Then...

    Search the web for more information on the methods and properties of the Cookies collection.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Mar 2004
    Location
    India
    Posts
    56
    Thanx for yourn greate Information , I will try it

  4. #4
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    And here are a few general cookie resources:

    Cookie Monster: Using Cookies in ASP by Ian Stallings - 5/10/1999
    http://www.4guysfromrolla.com/webtech/051099-1.shtml

    Cookie
    http://www.asp101.com/samples/cookie.asp

    How do I detect ENABLED cookies / javascript?
    http://www.aspfaq.com/show.asp?id=2058
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •