...

View Full Version : Session_OnStart! 5 years old post on codingforums



sasha85
10-26-2007, 03:20 PM
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!

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



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

sasha85
10-26-2007, 10:38 PM
i checked - the global.asa works fine with my files
i tried to set only

<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

sasha85
10-27-2007, 01:19 PM
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

BarrMan
10-27-2007, 04:04 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum