counter

B

Brian

Hi
im trying to build a page counter type thing which will update a database on the number of times a certain page has been opened... however if a person skips to another page and back again during the same "Session" i dont want the counter to increment.... ive looked at session variables but this mightnt work as they are changing constantly for the application... i want to be able to count how many times a photo gallery, album and image are accessed in the gallery. the galleries contain albums which contain photos, but i dont want to increment the album viewed number each time a user flicks back from an image to select another image

Is there like a unique session ID type thing that is assigned to a user that i can use to compare ?
 
X

xxxxx

On Sat, 10 Apr 2004 08:16:03 -0700, "=?Utf-8?B?QnJpYW4=?="

create a session variable ...

session("album_viewed")

then...

if session("album_viewed") = "" then
session("album_viewed") = "true"
REM - increment and persist in some storage...
end if

For that session it won't increment again if it finds string "true".
 
B

Brian

thanks for the reply..

but - if they go and open a different album and then come back to this one in the same session, i dont want it to increment again.... the problem is caused by having lots of albums. i want it to increment for each album they view, but not if they return to an album they have already viewed in the same session... any ideas

cheers, Brian
 
E

Evertjan.

=?Utf-8?B?QnJpYW4=?= wrote on 10 apr 2004 in
microsoft.public.inetserver.asp.general:
From: (e-mail address removed)
Newsgroups: microsoft.public.inetserver.asp.general
but - if they go and open a different album and then come back to this
one in the same session, i dont want it to increment again.... the
problem is caused by having lots of albums. i want it to increment for
each album they view, but not if they return to an album they have
already viewed in the same session... any ideas ?

give each album its own session variable:

session("album1")
session("album2")
session("album3")
 
R

Roland Hall

in message
: thanks for the reply...
:
: but - if they go and open a different album and then come back to this one
in the same session, i dont want it to increment again.... the problem is
caused by having lots of albums. i want it to increment for each album they
view, but not if they return to an album they have already viewed in the
same session... any ideas ?

I can think of two:

1. index each album they view and check the index before incrementing the
counter
2. use binary and assign a different value to each index, using a running
total of the total number of unique views and the index value, you can
determine if they have viewed the album.

#1 is easier to implement. Put a dynamic array in a session variable and
redimension it when you need to add another element. Search the array
before incrementing the counter, branching to add if it returns false or
exit if it returns true.


--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
X

xxxxx

On Sat, 10 Apr 2004 08:46:02 -0700, "=?Utf-8?B?QnJpYW4=?="

if your galleries are in directories and your albums are in html/asp
files and your images are in .gif files for each user, on session
start you could use the file system object to grab the collections of
all of these, loop through and create an array (or dictionary) for
them... so you'll have one session variable holding a dictionary
object for each gallery, album, and picture for a user session.
You'll have a name/value pair of "thingname"/"visit_count" and upon
getting the page, check the name of the file or thing, then look it up
in the dictionary, then increment... so you'll have all this stuff
itemized for the session in dictionaries... then if you want to
persist it, dump it into a database table (or just go ahead and use an
..mdb file with ADO in the first place) or somehow dump it into a text
file (which would be a mess)...

Better yet, you might be able to find a commerical component that does
this!!!

NOTE:
Remember that session variables are variants, so when you want to grab
your "object" type from the session variable, you'll have to create
the object again on the current page, then set that variable "=" to
the session("") variable...

'''' On a current .asp page (this is pseudocode) ''''
Set x = Server.createObject("scripting.dictionary")
x = Session("albumdictionaryobject")
x....method...

'increment the value in dict. where name is albumname, etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top