Click here to Skip to main content
Licence 
First Posted 1 Feb 2000
Views 136,726
Bookmarked 36 times

Working with cookies

By | 1 Feb 2000 | Article
An introduction to using cookies in your ASP scripts
  • Download source files - 3 Kb
  • Overview

    This is a small ASP (Microsoft Active Server Pages) application that implements basically work with cookies.
    The project has next main-functionality:

    • read cookies
    • write cookies
    • set expired date for cookies
    The page contains a help that make your work easy with the project. The sample is ready to use.

    Details

    The project has three important parts:

    1. Test if the client browser support cookies.

      For that I use the Browser Capabilities component (“MSWC.BrowserType”)

      	set objBrowserCapabilities = server.CreateObject("MSWC.BrowserType")
      	
      	' ...
      	
      	blnSupportCookies = objBrowserCapabilities.cookies
      	
      	' ...
      
    2. Read and display cookies

      For that I use the Request.Cookies collection. (See the ASP built-in objects.)

    3. Write cookies to client browser

      For that I use the Response.Cookies collection. (See the ASP built-in objects.)

    Usage


        The cookies have two forms:(See http://www.microsoft.com/info/cookies.htm)

    • normal cookies
    • dictionary cookies

    If you want write a normal cookie then specify a value in the Cookie Name field (this field is required) and a value in the Cookie Value field. If you want to write a dictionary cookie first you must type the number of keys (must be great 0) and then click 'Write cookie dictionary'. The page is then setup with your options and you can type values for your cookie dictionary. After you put the values in fields click 'Submit'. The cookie is written to the browser and is automatically read and displayed on the page.

    If you don’t set an expire value then your cookie lifetime will end after you shut down the current session. To extend yours cookies lifetime, you must set the Date and Hour values.

    Please feel free to ask any questions you have by e-mail: iulian_iuga@yahoo.com

    That's it!

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Iulian Iuga

    Web Developer

    Germany Germany

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralMy vote of 1 PinmemberMember 38207780:46 4 Aug '09  
    GeneralI agree with Tom! This code is worthless PinsussBrian11:54 7 Feb '00  
    GeneralRe: I agree with Tom! This code is worthless PinsussIulian Iuga3:14 8 Feb '00  
    GeneralRe: I agree with Tom! This code is worthless PinsussRonny Dahl3:43 10 Mar '00  
    GeneralRe: I agree with Tom! This code is worthless PinsussIulian Iuga3:41 8 Feb '00  
    GeneralRe: answers PinsussBrian9:41 9 Feb '00  
    GeneralRe: answers PinsussIulian Iuga20:51 9 Feb '00  
    GeneralRe: answers PinsussAnonymous16:24 27 Aug '02  
    GeneralRe: answers PinsussAnonymous5:17 3 Jul '03  
    GeneralRe: answers PinsussAnonymous19:13 6 Aug '03  
    GeneralCookies Test not "safe" PinsussTom Wellige21:05 3 Feb '00  
    GeneralRe: Cookies Test not PinsussUwe Keim2:46 6 Feb '00  
    GeneralRe: Cookies Test not PinsussTom Wellige21:12 6 Feb '00  
    >No, you have to test it in a real cookie, not just a
    >session.
     
    If cookies are disabled you won't get the value you have written into a session variable back when asking for it on another page.
     
    I agree that writing directly into a cookie is more abvious to get the wanted result, but using session variables will work also.
    GeneralRe: Cookies Test not PinsussUwe Keim21:23 6 Feb '00  
    GeneralRe: Cookies Test not PinsussTom Wellige22:17 6 Feb '00  
    GeneralRe: Cookies Test not PinsussIulian Iuga21:22 6 Feb '00  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Mobile
    Web04 | 2.5.120604.1 | Last Updated 2 Feb 2000
    Article Copyright 2000 by Iulian Iuga
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid