Add to Favorites    Make Home Page 3143 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Sessions Home » VBScript Cookie/Counter

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title VBScript Cookie/Counter
Description Not only does this sample show you how to create a counter, but more impotantly, it shows you how to create a cookie, which in todays world is a MUST HAVE tool. Cookies are anywhere and everywhere, they can store all kinds of information too, all you have to do is add an extra line (textline/field) in the file for each piece of information that you wish to persist.
Category ASP » Sessions
Hits 382576
Code Select and Copy the Code
1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document STEP 1 Be sure To enclose the code below In SCRIPT tags, both start And End are required. 'The name of the subroutine Sub CookieActions 'declare the constants which we will use ' Const ForReading=1, ForWriting=2, TristateFalse=0 'declare the local variables which we wi ' ll use 'fso = the file scripting object 'MyFile = the file where we will persist ' our data 'MyStream = the textstream object we wil ' l use to access the file 'MyTitle = on of our data fields - the t ' itle of the page 'MyData = another of our fields - the da ' ta in question, in this case a counter Dim fso, MyFile, MyStream, MyTitle, MyData, MyVisits 'initialise/create the file scripting ob ' ject Set fso=CreateObject("Scripting.FileSystemObject") 'test to see if our file already exists 'Note: 'Our file is zaf@drzed-VbsCountaDemoHtm. ' txt, and is in c:windowscookies If (fso.FileExists("c:[email protected]")) Then 'it does exist, so we will get the file Set MyFile = fso.GetFile("c:[email protected]") 'open the textstream object for reading Set MyStream = MyFile.OpenAsTextStream(ForReading) 'read the first line and assign it to ou ' r title variable MyTitle = MyStream.ReadLine 'read the second line and assign it to o ' ur data variable MyData = Mystream.ReadLine 'close the textstream object, and file a ' ll in one go MyStream.Close 'extract our data from the data string, ' by only excluding the first 7 characters ' , (thats 'VISITS=') MyVisits = Right(MyData,Len(MyData)-7) 'increment the counter, to include this ' visit MyVisits = MyVisits + 1 'display message box, to show the inform ' ation MsgBox "Title: " & MyTitle & vbCrLf & "Visits: " & MyVisits & vbCrLf & "http://home.clara.net/doczaf/index.html",,"Dr Zed Productions." 'get the file ready, so that we can writ ' e out the updated data Set MyFile = fso.GetFile("c:[email protected]") 're-open the textstream, this time for w ' riting Set MyStream = MyFile.OpenAsTextStream(ForWriting, TristateFalse) 'write out the first line, the page titl ' e MyStream.WriteLine "Splash Screen Counter" 'write out the last line, the updated co ' unter value, prefixed with the text 'VIS ' ITS=' MyStream.WriteLine "Visits=" & MyVisits 'close the textstream and file, all in o ' ne go MyStream.Close Else 'the file does not exist, so create it b ' y opening it Set myfile = fso.CreateTextFile("c:[email protected]", True) 'write out the first line, the page titl ' e MyFile.WriteLine("Splash Screen Counter") 'write out the last line, the initial co ' unter value, prefixed with the text 'VIS ' ITS=' MyFile.WriteLine("Visits=1") 'close the file MyFile.Close 'display message box, to show the inform ' ation MsgBox "Welcome To My Site" & vbCrLf &" Visits: 1"& "http://home.clara.net/doczaf/index.html", ,"Dr Zed Productions." End If End Sub STEP 2 Be sure To include the following Text In your BODY tag ONLOAD="CookieActions" FURTHER INFO Not only does this sample show you how To create a counter, but more impotantly, it shows you how To create a cookie, which In todays world Is a MUST HAVE tool. Cookies are anywhere And everywhere, they can store all kinds of information too, all you have To Do Is add an extra line (textline/field) In the file For Each piece of information that you wish To persist. DocZaf Enjoy

Related Source Codes

Script Name Author
��������������������� VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=248


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review