ASP does not save data in Session

Asked

Viewed 240 times

2

I have a page that logs in from the customer. That page goes up to the Session account id and name like this:

session("user_id") = rec_user("chave")
session("user_name") = rec_user("nome)

I have another page that uses this information to check if the user is logged in:

if session("user_id") = "" then
    response.redirect("login.asp")
else
    'exibe a página
end if

The problem is that the page that does the checking never receives the data from session. I found the mistake strange for two reasons:

  • 1º as soon as I entered the data into session, on the login page, order a check to see if they were there, and returned positive.
  • 2º there is another login page, which searches users in a secondary table, but redirects to the same check page, and, strangely, the data uploaded to the session of this other login page are viewed perfectly by the verification page.
  • It should not have to do with the subject, but the typing error (the quote missing in the name) is only here in Sopt right? In the code is ok?

  • Is there not something else in the code on this first page of login, besides these two lines that you put as an example? Would it show the entire code? It’s pure ASP, or it’s ASP.Net?

1 answer

2

Well guys. I found the problem and I’ll share it. The page redirect was with full address with www. Example

response.redirect('http://www.exemplo.com')

But if the user accesses without the WWW (example.com) in the browser, the page that receives the redirect (which comes with www in the url) does not see the Session created on the page that saved the data with url without www. Here is the explanation for one login page to work and another not. The solution was simple, remove redirect with full url and place with relative url.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.