0

I have two asp pages in the first page named verify.asp i have write this code:

verify.asp

    <%
       Username = Request.Form("loginx")    
       Password = Request.Form("passx")
       liberado
       Session("liberado") = Username 

  %>

in the second page i try to use the session variabel "liberado" with any result barra.asp ,

<%
  response.write(session("liberado"))
%>

What i'm making wrong? I m using chrome on IIS of windows 7, Username and Password have values

alejandro carnero
  • 1,774
  • 7
  • 27
  • 43
  • You don't need to dim `liberado`, but you should dim `username` and `password`. As for your session being empty, I'd suspect that `loginx` isn't being posted. – Adam Mar 18 '19 at 18:31
  • It’s also possible that Session State is not enabled on the Web Application in IIS. – user692942 Mar 18 '19 at 20:16
  • 1
    Possible duplicate of [session not working in classic asp on iis server 8](https://stackoverflow.com/questions/16207195/session-not-working-in-classic-asp-on-iis-server-8) – user692942 Mar 18 '19 at 20:17
  • If session state was disabled I think that would result in a type mismatch error. – Adam Mar 18 '19 at 21:01
  • [How to use Session and Application variables in an ASP program](https://support.microsoft.com/en-gb/help/300883/how-to-use-session-and-application-variables-in-an-asp-program) – user692942 Mar 18 '19 at 21:42
  • @Adam not sure without testing it as all the official reference documentation for Classic ASP has been nuked by Microsoft. – user692942 Mar 18 '19 at 21:43

2 Answers2

1

There was nothing really wrong with your code. Although I can see you've edited it now to remove the dim from liberado, but you've left liberado behind. This means your ASP will try and call a sub called liberado, which presumably doesn't exist. You can go ahead and remove that line.

<%

    Dim Username, Password

    Username = Request.Form("loginx")
    Password = Request.Form("passx")

    Session("liberado") = Username 

%>

Trying to set a session whilst the session state is disabled will probably result in an error of some kind (and you didn't mention an error in your question). But make sure it's enabled by opening IIS and under ASP > Session Properties set "Enable Session State" to "True".

If it's already true then chances are there's something wrong with your form and the data isn't being posted. On your verify.asp page try running the following code:

for each item in request.form
    response.write item & ": " & request.form(item) & "<br>"
next

This will output a list of all the form data being posted.

This could also be a cookie issue. If you're blocking cookies from being set in Chrome then there won't be an ASP session cookie, so session values won't be accessible as you move from page to page.

In Chrome press F12 to open developer tools, click the Applications tab, and from the "Cookies" drop down menu select your domain. Check there's an ASPSESSIONID cookie present, and it's the same cookie on both your ASP pages.

Adam
  • 836
  • 2
  • 8
  • 13
1

Check the application pool settings in IIS. If there are multiple worker processes active under "maximum worker processes", sessions don't always work. Sessions are stored per process, do if a different worker process handles the second request, the session from the first request might be missing. A setting of "0" means IIS uses as many processes as needed.

More information here

enter image description here

Erik Oosterwaal
  • 4,272
  • 3
  • 44
  • 64