Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > counter

Reply
Thread Tools

counter

 
 
Brian
Guest
Posts: n/a
 
      04-10-2004
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 ?
 
Reply With Quote
 
 
 
 
xxxxx@hjjghgj.com
Guest
Posts: n/a
 
      04-10-2004
On Sat, 10 Apr 2004 08:16:03 -0700, "=?Utf-8?B?QnJpYW4=?="
<> wrote:

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".


>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 ?


 
Reply With Quote
 
 
 
 
Brian
Guest
Posts: n/a
 
      04-10-2004
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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      04-10-2004
=?Utf-8?B?QnJpYW4=?= wrote on 10 apr 2004 in
microsoft.public.inetserver.asp.general:
> From:
> Newsgroups: microsoft.public.inetserver.asp.general
>>
>> On Sat, 10 Apr 2004 08:16:03 -0700, "=?Utf-8?B?QnJpYW4=?="
>> <> wrote:
>> 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".

> 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")

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      04-10-2004
"Brian" wrote in message
news:310C221E-CED4-45CD-9A95-...
: 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


 
Reply With Quote
 
xxxxx@hjjghgj.com
Guest
Posts: n/a
 
      04-10-2004
On Sat, 10 Apr 2004 08:46:02 -0700, "=?Utf-8?B?QnJpYW4=?="
<> wrote:

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...



>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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page File counter and Private Bytes Counter George2 C++ 1 01-31-2008 09:27 AM
Reset network creation counter J.H. Holliday Wireless Networking 4 06-11-2005 08:09 PM
Session("counter") vs. ViewState("counter")...a newbie question The Eeediot ASP .Net 3 12-22-2004 09:31 PM
Java Applet counter doesn't display correctly Dick Stouffer Firefox 8 10-05-2004 04:52 PM
can I do such a simplest counter in VHDL? walala VHDL 3 09-14-2003 08:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57