Session variables

Discussion in 'ASP General' started by Lina Manjarres, Jul 20, 2005.

  1. Hello,

    I have a session variable in a login page. Then I go to a form page where I
    uses the ProfileID and the UserID. Then I go to a result page where I would
    like to use the UserID as a filter, but I can't get the value is stored in it.

    How can I do that?

    Thanks a lot!

    Lina
     
    Lina Manjarres, Jul 20, 2005
    #1
    1. Advertising

  2. ?? Can you give details? How are you trying to get the value? What do you
    mean when you say you can't? Do you get an error? Sample code? Are all
    the files in question in the same IIS application?

    Ray at work

    "Lina Manjarres" <> wrote in message
    news:...
    > Hello,
    >
    > I have a session variable in a login page. Then I go to a form page where

    I
    > uses the ProfileID and the UserID. Then I go to a result page where I

    would
    > like to use the UserID as a filter, but I can't get the value is stored in

    it.
    >
    > How can I do that?
    >
    > Thanks a lot!
    >
    > Lina
     
    Ray Costanzo [MVP], Jul 20, 2005
    #2
    1. Advertising

  3. All the files are in the same IIS application.
    I do not get error messages. A get the result wrong data'.
    The login filters Usr and Password and reads from SQL the profile. I need to
    use this profile in many pages from there on, and I can use it in the first
    page I go to. It seems like the Session variables were deleted or had a ver
    short live. Funny?

    So I have a login, and a validation page, and a Form page. Up until now
    every thisn is correct. The form page has a combo that is filled with a
    recorset and then all the values are sent using this jscipt:

    function PasaValoresFab()
    { var Fabrica = document.frmConsulta.Fabrica.value
    var VecFabrica = Fabrica.split("-");
    document.frmConsulta.cFabrica.value = VecFabrica[0]
    document.frmConsulta.NombreFabrica.value = VecFabrica[1]
    }

    This is the combo code:

    <select name="Fabrica" tabindex="10" onChange="javascript:pasaValoresFab();">
    <option selected>Escoja la fábrica</option>
    <%Call ComboGR(Fabricas)%>



    This is the code for the form:
    <form method="post" action="resultado.asp" name="frmConsulta"
    onSubmit="return ActivarFiltro();">

    And this is the code for the ActivarFiltro:
    if (document.frmConsulta.cFabrica.value != "")
    { Vec[12]="(MILL ='"+document.frmConsulta.cFabrica.value + "')"
    Vec2[12]="Fabrica = "+document.frmConsulta.cFabrica.value + " ("+
    document.frmConsulta.NombreFabrica.value +") "
    }


    Kind of confusing? The result page has this at some point:

    IF PACASOLA = "SI" THEN
    Call ActivarFiltroVB()
    ELSE

    Where Activar Filtro has this at some point:
    IF Session("PERFIL") = 3 THEN
    Ag = Session("CODIGO")
    Session("StrSQL") = Session("StrSQL") & "AND Agency = '" & Ag & "' "
    END IF
    If Session("PERFIL") =2 THEN
    Fa = Session("Codigo")
    Session("StrSQL") = Session("StrSQL") &" AND Agency is not null AND "
    Session("StrSQL") = Session("StrSQL") &" MILLS = '" & Fa & "' "
    END IF

    And here is part of the problem: the Session Variable PERFIL is lost, I
    can't make it work.

    Well, I guess it is all!

    Thanks a lot, Lina








    "Ray Costanzo [MVP]" wrote:

    > ?? Can you give details? How are you trying to get the value? What do you
    > mean when you say you can't? Do you get an error? Sample code? Are all
    > the files in question in the same IIS application?
    >
    > Ray at work
    >
    > "Lina Manjarres" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I have a session variable in a login page. Then I go to a form page where

    > I
    > > uses the ProfileID and the UserID. Then I go to a result page where I

    > would
    > > like to use the UserID as a filter, but I can't get the value is stored in

    > it.
    > >
    > > How can I do that?
    > >
    > > Thanks a lot!
    > >
    > > Lina

    >
    >
    >
     
    Lina Manjarres, Jul 20, 2005
    #3
  4. Lina Manjarres

    Bullschmidt Guest

    I didn't see where you actually set the session variables. But on a
    page receiving a post you could do something like this to set them:

    Session("UserName") = Request.Form("UserName")
    Session("UserLevel") = Request.Form("UserLevel")

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

    <<

    All the files are in the same IIS application.
    I do not get error messages. A get the result wrong data'.
    The login filters Usr and Password and reads from SQL the profile. I
    need to
    use this profile in many pages from there on, and I can use it in the
    first
    page I go to. It seems like the Session variables were deleted or had a
    ver
    short live. Funny?

    So I have a login, and a validation page, and a Form page. Up until now
    every thisn is correct. The form page has a combo that is filled with a
    recorset and then all the values are sent using this jscipt:

    function PasaValoresFab()
    { var Fabrica = document.frmConsulta.Fabrica.value
    var VecFabrica = Fabrica.split("-");
    document.frmConsulta.cFabrica.value = VecFabrica[0]
    document.frmConsulta.NombreFabrica.value = VecFabrica[1]
    }

    This is the combo code:

    <select name="Fabrica" tabindex="10"
    onChange="javascript:pasaValoresFab();">
    <option selected>Escoja la fã¡brica</option>
    <%Call ComboGR(Fabricas)%>



    This is the code for the form:
    <form method="post" action="resultado.asp" name="frmConsulta"
    onSubmit="return ActivarFiltro();">

    And this is the code for the ActivarFiltro:
    if (document.frmConsulta.cFabrica.value != "")
    { Vec[12]="(MILL ='"+document.frmConsulta.cFabrica.value +
    "')"
    Vec2[12]="Fabrica = "+document.frmConsulta.cFabrica.value +
    " ("+
    document.frmConsulta.NombreFabrica.value +") "
    }


    Kind of confusing? The result page has this at some point:

    IF PACASOLA = "SI" THEN
    Call ActivarFiltroVB()
    ELSE

    Where Activar Filtro has this at some point:
    IF Session("PERFIL") = 3 THEN
    Ag = Session("CODIGO")
    Session("StrSQL") = Session("StrSQL") & "AND Agency = '" & Ag &
    "' "
    END IF
    If Session("PERFIL") =2 THEN
    Fa = Session("Codigo")
    Session("StrSQL") = Session("StrSQL") &" AND Agency is not null
    AND "
    Session("StrSQL") = Session("StrSQL") &" MILLS = '" & Fa & "' "
    END IF

    And here is part of the problem: the Session Variable PERFIL is lost, I
    can't make it work.

    Well, I guess it is all!

    Thanks a lot, Lina
    >>


    *** Sent via Developersdex http://www.developersdex.com ***
     
    Bullschmidt, Jul 21, 2005
    #4
  5. Oh! Yes... I have a login page where I read the session variables as this:

    StrCons = "SELECT * FROM mills WHERE sigla='"& Usuario &"' and Clave='"&
    Clave &"'"
    Call Consulta(StrCons,RSDatos,MotorBD,DSource,InCat,UsuarioSQL,Password)
    IF NOT RSDatos.EOF AND NOT RSDatos.BOF THEN
    Session("NIT") = RSDatos(2) 'Nit del usuario
    Session("Fabrica") = RSDatos(1) 'Nombre del usuario
    Session("Perfil") = RSDatos(4) 'PERFIL DEL USUARIO: FABRICA=2, AGENCIA=3,
    DIAGONAL=1
    Session("Codigo") = RSDatos(0) 'Codigo del usuario
    Session("Filtro") = Request("Filtro")
    Call CerrarConsulta("RSDatos")
    Call CerrarConexion("Conexion")
    Response.redirect PaginaDestino


    Thks, Lina

    "Bullschmidt" wrote:

    > I didn't see where you actually set the session variables. But on a
    > page receiving a post you could do something like this to set them:
    >
    > Session("UserName") = Request.Form("UserName")
    > Session("UserLevel") = Request.Form("UserLevel")
    >
    > Best regards,
    > J. Paul Schmidt, Freelance ASP Web Developer
    > http://www.Bullschmidt.com
    > ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
    >
    > <<
    >
    > All the files are in the same IIS application.
    > I do not get error messages. A get the result wrong data'.
    > The login filters Usr and Password and reads from SQL the profile. I
    > need to
    > use this profile in many pages from there on, and I can use it in the
    > first
    > page I go to. It seems like the Session variables were deleted or had a
    > ver
    > short live. Funny?
    >
    > So I have a login, and a validation page, and a Form page. Up until now
    > every thisn is correct. The form page has a combo that is filled with a
    > recorset and then all the values are sent using this jscipt:
    >
    > function PasaValoresFab()
    > { var Fabrica = document.frmConsulta.Fabrica.value
    > var VecFabrica = Fabrica.split("-");
    > document.frmConsulta.cFabrica.value = VecFabrica[0]
    > document.frmConsulta.NombreFabrica.value = VecFabrica[1]
    > }
    >
    > This is the combo code:
    >
    > <select name="Fabrica" tabindex="10"
    > onChange="javascript:pasaValoresFab();">
    > <option selected>Escoja la fc!brica</option>
    > <%Call ComboGR(Fabricas)%>
    >
    >
    >
    > This is the code for the form:
    > <form method="post" action="resultado.asp" name="frmConsulta"
    > onSubmit="return ActivarFiltro();">
    >
    > And this is the code for the ActivarFiltro:
    > if (document.frmConsulta.cFabrica.value != "")
    > { Vec[12]="(MILL ='"+document.frmConsulta.cFabrica.value +
    > "')"
    > Vec2[12]="Fabrica = "+document.frmConsulta.cFabrica.value +
    > " ("+
    > document.frmConsulta.NombreFabrica.value +") "
    > }
    >
    >
    > Kind of confusing? The result page has this at some point:
    >
    > IF PACASOLA = "SI" THEN
    > Call ActivarFiltroVB()
    > ELSE
    >
    > Where Activar Filtro has this at some point:
    > IF Session("PERFIL") = 3 THEN
    > Ag = Session("CODIGO")
    > Session("StrSQL") = Session("StrSQL") & "AND Agency = '" & Ag &
    > "' "
    > END IF
    > If Session("PERFIL") =2 THEN
    > Fa = Session("Codigo")
    > Session("StrSQL") = Session("StrSQL") &" AND Agency is not null
    > AND "
    > Session("StrSQL") = Session("StrSQL") &" MILLS = '" & Fa & "' "
    > END IF
    >
    > And here is part of the problem: the Session Variable PERFIL is lost, I
    > can't make it work.
    >
    > Well, I guess it is all!
    >
    > Thanks a lot, Lina
    > >>

    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    Lina Manjarres, Jul 21, 2005
    #5
  6. Lina Manjarres

    Patrice Guest

    I don't see the "end if". If there is no record could the user proceed to
    the next page without having session variables propery set ?

    IMO the first step would be to set a seession variable on the first page and
    writing the value on the second page. It should allow to see if this a
    problem with session variables or with the logic used...
    You can also write down the sessionid on both pages to see if this is the
    same...

    Good luck.
    --

    Patrice

    "Lina Manjarres" <> a écrit dans le
    message de news:...
    > Oh! Yes... I have a login page where I read the session variables as this:
    >
    > StrCons = "SELECT * FROM mills WHERE sigla='"& Usuario &"' and Clave='"&
    > Clave &"'"
    > Call Consulta(StrCons,RSDatos,MotorBD,DSource,InCat,UsuarioSQL,Password)
    > IF NOT RSDatos.EOF AND NOT RSDatos.BOF THEN
    > Session("NIT") = RSDatos(2) 'Nit del usuario
    > Session("Fabrica") = RSDatos(1) 'Nombre del usuario
    > Session("Perfil") = RSDatos(4) 'PERFIL DEL USUARIO: FABRICA=2, AGENCIA=3,
    > DIAGONAL=1
    > Session("Codigo") = RSDatos(0) 'Codigo del usuario
    > Session("Filtro") = Request("Filtro")
    > Call CerrarConsulta("RSDatos")
    > Call CerrarConexion("Conexion")
    > Response.redirect PaginaDestino
    >
    >
    > Thks, Lina
    >
    > "Bullschmidt" wrote:
    >
    > > I didn't see where you actually set the session variables. But on a
    > > page receiving a post you could do something like this to set them:
    > >
    > > Session("UserName") = Request.Form("UserName")
    > > Session("UserLevel") = Request.Form("UserLevel")
    > >
    > > Best regards,
    > > J. Paul Schmidt, Freelance ASP Web Developer
    > > http://www.Bullschmidt.com
    > > ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
    > >
    > > <<
    > >
    > > All the files are in the same IIS application.
    > > I do not get error messages. A get the result wrong data'.
    > > The login filters Usr and Password and reads from SQL the profile. I
    > > need to
    > > use this profile in many pages from there on, and I can use it in the
    > > first
    > > page I go to. It seems like the Session variables were deleted or had a
    > > ver
    > > short live. Funny?
    > >
    > > So I have a login, and a validation page, and a Form page. Up until now
    > > every thisn is correct. The form page has a combo that is filled with a
    > > recorset and then all the values are sent using this jscipt:
    > >
    > > function PasaValoresFab()
    > > { var Fabrica = document.frmConsulta.Fabrica.value
    > > var VecFabrica = Fabrica.split("-");
    > > document.frmConsulta.cFabrica.value = VecFabrica[0]
    > > document.frmConsulta.NombreFabrica.value = VecFabrica[1]
    > > }
    > >
    > > This is the combo code:
    > >
    > > <select name="Fabrica" tabindex="10"
    > > onChange="javascript:pasaValoresFab();">
    > > <option selected>Escoja la fc!brica</option>
    > > <%Call ComboGR(Fabricas)%>
    > >
    > >
    > >
    > > This is the code for the form:
    > > <form method="post" action="resultado.asp" name="frmConsulta"
    > > onSubmit="return ActivarFiltro();">
    > >
    > > And this is the code for the ActivarFiltro:
    > > if (document.frmConsulta.cFabrica.value != "")
    > > { Vec[12]="(MILL ='"+document.frmConsulta.cFabrica.value +
    > > "')"
    > > Vec2[12]="Fabrica = "+document.frmConsulta.cFabrica.value +
    > > " ("+
    > > document.frmConsulta.NombreFabrica.value +") "
    > > }
    > >
    > >
    > > Kind of confusing? The result page has this at some point:
    > >
    > > IF PACASOLA = "SI" THEN
    > > Call ActivarFiltroVB()
    > > ELSE
    > >
    > > Where Activar Filtro has this at some point:
    > > IF Session("PERFIL") = 3 THEN
    > > Ag = Session("CODIGO")
    > > Session("StrSQL") = Session("StrSQL") & "AND Agency = '" & Ag &
    > > "' "
    > > END IF
    > > If Session("PERFIL") =2 THEN
    > > Fa = Session("Codigo")
    > > Session("StrSQL") = Session("StrSQL") &" AND Agency is not null
    > > AND "
    > > Session("StrSQL") = Session("StrSQL") &" MILLS = '" & Fa & "' "
    > > END IF
    > >
    > > And here is part of the problem: the Session Variable PERFIL is lost, I
    > > can't make it work.
    > >
    > > Well, I guess it is all!
    > >
    > > Thanks a lot, Lina
    > > >>

    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > >
     
    Patrice, Jul 21, 2005
    #6
  7. Lina Manjarres

    Patrice Guest

    I meant set/write session variables *without any condition* to see if this
    is a logic problem or really a technical problem with the session.

    --

    "Patrice" <> a écrit dans le message de
    news:%...
    > I don't see the "end if". If there is no record could the user proceed to
    > the next page without having session variables propery set ?
    >
    > IMO the first step would be to set a seession variable on the first page

    and
    > writing the value on the second page. It should allow to see if this a
    > problem with session variables or with the logic used...
    > You can also write down the sessionid on both pages to see if this is the
    > same...
    >
    > Good luck.
    > --
    >
    > Patrice
    >
    > "Lina Manjarres" <> a écrit dans le
    > message de news:...
    > > Oh! Yes... I have a login page where I read the session variables as

    this:
    > >
    > > StrCons = "SELECT * FROM mills WHERE sigla='"& Usuario &"' and Clave='"&
    > > Clave &"'"
    > > Call Consulta(StrCons,RSDatos,MotorBD,DSource,InCat,UsuarioSQL,Password)
    > > IF NOT RSDatos.EOF AND NOT RSDatos.BOF THEN
    > > Session("NIT") = RSDatos(2) 'Nit del usuario
    > > Session("Fabrica") = RSDatos(1) 'Nombre del usuario
    > > Session("Perfil") = RSDatos(4) 'PERFIL DEL USUARIO: FABRICA=2,

    AGENCIA=3,
    > > DIAGONAL=1
    > > Session("Codigo") = RSDatos(0) 'Codigo del usuario
    > > Session("Filtro") = Request("Filtro")
    > > Call CerrarConsulta("RSDatos")
    > > Call CerrarConexion("Conexion")
    > > Response.redirect PaginaDestino
    > >
    > >
    > > Thks, Lina
    > >
    > > "Bullschmidt" wrote:
    > >
    > > > I didn't see where you actually set the session variables. But on a
    > > > page receiving a post you could do something like this to set them:
    > > >
    > > > Session("UserName") = Request.Form("UserName")
    > > > Session("UserLevel") = Request.Form("UserLevel")
    > > >
    > > > Best regards,
    > > > J. Paul Schmidt, Freelance ASP Web Developer
    > > > http://www.Bullschmidt.com
    > > > ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
    > > >
    > > > <<
    > > >
    > > > All the files are in the same IIS application.
    > > > I do not get error messages. A get the result wrong data'.
    > > > The login filters Usr and Password and reads from SQL the profile. I
    > > > need to
    > > > use this profile in many pages from there on, and I can use it in the
    > > > first
    > > > page I go to. It seems like the Session variables were deleted or had

    a
    > > > ver
    > > > short live. Funny?
    > > >
    > > > So I have a login, and a validation page, and a Form page. Up until

    now
    > > > every thisn is correct. The form page has a combo that is filled with

    a
    > > > recorset and then all the values are sent using this jscipt:
    > > >
    > > > function PasaValoresFab()
    > > > { var Fabrica = document.frmConsulta.Fabrica.value
    > > > var VecFabrica = Fabrica.split("-");
    > > > document.frmConsulta.cFabrica.value = VecFabrica[0]
    > > > document.frmConsulta.NombreFabrica.value = VecFabrica[1]
    > > > }
    > > >
    > > > This is the combo code:
    > > >
    > > > <select name="Fabrica" tabindex="10"
    > > > onChange="javascript:pasaValoresFab();">
    > > > <option selected>Escoja la fc!brica</option>
    > > > <%Call ComboGR(Fabricas)%>
    > > >
    > > >
    > > >
    > > > This is the code for the form:
    > > > <form method="post" action="resultado.asp" name="frmConsulta"
    > > > onSubmit="return ActivarFiltro();">
    > > >
    > > > And this is the code for the ActivarFiltro:
    > > > if (document.frmConsulta.cFabrica.value != "")
    > > > { Vec[12]="(MILL ='"+document.frmConsulta.cFabrica.value +
    > > > "')"
    > > > Vec2[12]="Fabrica = "+document.frmConsulta.cFabrica.value

    +
    > > > " ("+
    > > > document.frmConsulta.NombreFabrica.value +") "
    > > > }
    > > >
    > > >
    > > > Kind of confusing? The result page has this at some point:
    > > >
    > > > IF PACASOLA = "SI" THEN
    > > > Call ActivarFiltroVB()
    > > > ELSE
    > > >
    > > > Where Activar Filtro has this at some point:
    > > > IF Session("PERFIL") = 3 THEN
    > > > Ag = Session("CODIGO")
    > > > Session("StrSQL") = Session("StrSQL") & "AND Agency = '" & Ag

    &
    > > > "' "
    > > > END IF
    > > > If Session("PERFIL") =2 THEN
    > > > Fa = Session("Codigo")
    > > > Session("StrSQL") = Session("StrSQL") &" AND Agency is not

    null
    > > > AND "
    > > > Session("StrSQL") = Session("StrSQL") &" MILLS = '" & Fa & "'

    "
    > > > END IF
    > > >
    > > > And here is part of the problem: the Session Variable PERFIL is lost,

    I
    > > > can't make it work.
    > > >
    > > > Well, I guess it is all!
    > > >
    > > > Thanks a lot, Lina
    > > > >>
    > > >
    > > > *** Sent via Developersdex http://www.developersdex.com ***
    > > >

    >
    >
     
    Patrice, Jul 21, 2005
    #7
    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. Earl Teigrob

    Global Session Variables and Session State

    Earl Teigrob, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,278
    Alvin Bruney
    Dec 17, 2003
  2. =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?=

    Session Variables assigned to the wrong session?

    =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?=, Jan 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    714
    Alvin Bruney [MVP]
    Jan 20, 2005
  3. Robert Faulkner
    Replies:
    0
    Views:
    882
    Robert Faulkner
    Jan 28, 2005
  4. Replies:
    1
    Views:
    938
  5. Replies:
    9
    Views:
    961
Loading...

Share This Page