Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Netscape Session_OnStart! 5 years old post on codingforums

    that is the last time
    http://www.codingforums.com/showthread.php?t=980
    someone asked about this...and no one knew than...it was 2002...
    now the question is:

    this code works! it puts the 1 in field "online"
    if i will open asp file with that code alone and i will enter this asp with session it will give me "1" perfectly!
    Code:
    dim mysql, connasa, connstringasa
    Set connasa = Server.CreateObject("ADODB.Connection")
    ConnStringasa = "Driver={MySQL ODBC 3.51 Driver};Server=mySQL4.domain.com;database=user;user=user;password=pass;OPTION=3"                        
    
    Connasa.Open ConnStringasa
    
    if Session("usernameid")<>"" then
    
    vab=Session("usernameid")
    
     mySQL="UPDATE crmagents SET online=1 WHERE username='" & vab & "'"
    
    connasa.execute(mySQL)
    
    end if
    
    Connasa.close
    but when i put the same code in the global.asa
    like this

    Code:
    <script language="vbscript" runat="server">
    Sub Session_OnStart
    dim mysql, connasa, connstringasa
    Set connasa = Server.CreateObject("ADODB.Connection")
    ConnStringasa = "Driver={MySQL ODBC 3.51 Driver};Server=mySQL4.domain.com;database=user;user=user;password=pass;OPTION=3"                        
    
    Connasa.Open ConnStringasa
    
    if Session("usernameid")<>"" then
    
    vab=Session("usernameid")
    
     mySQL="UPDATE crmagents SET online=1 WHERE username='" & vab & "'"
    
    connasa.execute(mySQL)
    
    end if
    
    Connasa.close
    end sub
    </script>
    when i enter pages with the right sessions...i got nothing...just like it not works...
    why? whyyyy me?
    Last edited by sasha85; 10-26-2007 at 11:09 PM.
    By the time u recognize this moment, This moment will be gone.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts
    i checked - the global.asa works fine with my files
    i tried to set only
    Code:
    <script language="vbscript" runat="server">
    Sub Session_OnStart
    response.redirect "www.yahoo.com"
    end sub
    </script>
    and i was redirected from all the pages...

    then the prob is not with the catch of files
    By the time u recognize this moment, This moment will be gone.

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts
    the problem is that when the user login and and get the Session("usernameid") the globla.asa not recognize the session...
    i tested it 2 ways- to give the Session("usernameid")=username and only than to redirect the page
    and the second way i first redirected the user and only then on the redirected page i gave Session("usernameid")=session("username")

    and on the global i changed the "if" into:
    if Session("usernameid")<>"" or Session("username")<>"" then
    By the time u recognize this moment, This moment will be gone.

  • #4
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    The Session_OnStart event occurs when the user first joins the website. It doesn't matter what page he's visiting on your site. It's even before the page is even loaded so don't try searching for Sessions values because they will all be null.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •