counter

Discussion in 'ASP General' started by Brian, Apr 10, 2004.

  1. Brian

    Brian Guest

    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 ?
    Brian, Apr 10, 2004
    #1
    1. Advertising

  2. Brian

    Guest

    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 ?
    , Apr 10, 2004
    #2
    1. Advertising

  3. Brian

    Brian Guest

    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
    Brian, Apr 10, 2004
    #3
  4. Brian

    Evertjan. Guest

    =?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)
    Evertjan., Apr 10, 2004
    #4
  5. Brian

    Roland Hall Guest

    "Brian" wrote in message
    news:...
    : 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
    Roland Hall, Apr 10, 2004
    #5
  6. Brian

    Guest

    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
    , Apr 10, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    10,128
    VhdlCohen
    Sep 14, 2003
  2. Jan Kindt
    Replies:
    1
    Views:
    1,492
    Jim Lewis
    Sep 17, 2003
  3. dong seok huh

    [Q] : async event counter

    dong seok huh, Oct 1, 2003, in forum: VHDL
    Replies:
    6
    Views:
    755
    Renaud Pacalet
    Oct 6, 2003
  4. The Eeediot
    Replies:
    3
    Views:
    2,224
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  5. George2
    Replies:
    1
    Views:
    791
    Alf P. Steinbach
    Jan 31, 2008
Loading...

Share This Page