1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Sub Session_OnStart!!?

Discussion in 'C#' started by hantz, Oct 26, 2007.

  1. #1
    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!
    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
    Code (markup):
    but when i put the same code in the global.asa
    like this

    
    <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
    set Connasa=nothing
    end sub
    </script>
    Code (markup):
    when i enter pages with the right sessions...i got nothing...just like it not works...
    why? whyyyy me?:)
    SEMrush
     
    hantz, Oct 26, 2007 IP
    SEMrush
  2. hantz

    hantz Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    hantz, Oct 27, 2007 IP