5,693,062 members and growing! (20,274 online)
Email Password   helpLost your password?
Web Development » ASP » General     Beginner

Working with cookies

By Iulian Iuga

An introduction to using cookies in your ASP scripts
VBScriptNT4, Windows, ASP, IIS, Dev

Posted: 1 Feb 2000
Updated: 1 Feb 2000
Views: 115,293
Bookmarked: 26 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
37 votes for this Article.
Popularity: 3.65 Rating: 2.32 out of 5
5 votes, 55.6%
1
1 vote, 11.1%
2
1 vote, 11.1%
3
1 vote, 11.1%
4
1 vote, 11.1%
5
  • 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



    Occupation: Web Developer
    Location: Germany Germany

    Other popular ASP articles:

    Article Top
    Sign Up to vote for this article
    You must Sign In to use this message board.
    FAQ FAQ Noise ToleranceSearch Search Messages 
     Layout  Per page   
     Msgs 1 to 15 of 15 (Total in Forum: 15) (Refresh)FirstPrevNext
    GeneralI agree with Tom! This code is worthlesssussBrian12:54 7 Feb '00  
    GeneralRe: I agree with Tom! This code is worthlesssussIulian Iuga4:14 8 Feb '00  
    GeneralRe: I agree with Tom! This code is worthlesssussRonny Dahl4:43 10 Mar '00  
    GeneralRe: I agree with Tom! This code is worthlesssussIulian Iuga4:41 8 Feb '00  
    GeneralRe: answerssussBrian10:41 9 Feb '00  
    GeneralRe: answerssussIulian Iuga21:51 9 Feb '00  
    GeneralRe: answerssussAnonymous17:24 27 Aug '02  
    GeneralRe: answerssussAnonymous6:17 3 Jul '03  
    GeneralRe: answerssussAnonymous20:13 6 Aug '03  
    GeneralCookies Test not "safe"sussTom Wellige22:05 3 Feb '00  
    GeneralRe: Cookies Test not sussUwe Keim3:46 6 Feb '00  
    GeneralRe: Cookies Test not sussTom Wellige22:12 6 Feb '00  
    GeneralRe: Cookies Test not sussUwe Keim22:23 6 Feb '00  
    GeneralRe: Cookies Test not sussTom Wellige23:17 6 Feb '00  
    GeneralRe: Cookies Test not sussIulian Iuga22:22 6 Feb '00  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 1 Feb 2000
    Editor: Chris Maunder
    Copyright 2000 by Iulian Iuga
    Everything else Copyright © CodeProject, 1999-2008
    Web13 | Advertise on the Code Project