p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   session (http://p2p.wrox.com/showthread.php?t=45362)

lakshmi devi July 18th, 2006 04:58 AM

session
 
hi,

i am new to ASP.my problem is when i create session. the value in the session is expired soon.session value is null in all the pages.this is my code
where i am validating the values entered in the textbox
dim con
set con=server.CreateObject("ADODB.Connection")
con.open strDB '' connectionstring

dim uname,pwd
uname=Request.Form("txtuser")
pwd=Request.Form("txtpwd")
Response.Write(uname&" <br>" & pwd & "<br>")

dim rs
set rs=Server.CreateObject("ADODB.Recordset")
rs.open con.Execute("Select * from Adminlogin where A_Username='"&trim(uname)&"' and A_pwd='"&trim(pwd)&"' ")
    if rs.EOF then
        Response.Write("Invaid Login Details")
    else
        Session("LoggedInUser") =rs("A_Username")
        Response.Redirect("Admin Control Panel.asp")


    end if '' end if of rs record set



this is another page's code

If Session("LoggedInUser") = "" Then
    Response.Redirect("../default.htm")
End If
session value is always null in this page.

textboxes are in default.htm page.


thanks in advance







Steweb July 18th, 2006 08:12 AM

Hi,!

Code:

if rs.EOF then
        Response.Write("Invaid Login Details")
    else
        Session("LoggedInUser") =rs("A_Username")

        response.write (rs("A_Username"))
        response.write (Session("LoggedInUser"))
        response.end
        Response.Redirect("Admin Control Panel.asp")
    end if '' end if of rs record set



try now

Steweb




Visit my web site !
www.steweb.net

lakshmi devi July 19th, 2006 05:53 AM

hi,


response.write (rs("A_Username"))
response.write (Session("LoggedInUser"))

this line of code is working.displaying username.but when this page is redirected

example: Response.Redirect("Admin Control Panel.asp")

Admincontrolpage.asp page is opened

response.write (Session("LoggedInUser")) this code is not working.session value is not printed.

session value is null in Admincontrolpage.asp page

thank u steweb








Steweb July 19th, 2006 10:56 AM

MMM...

maby you use a browser Firefox or netscape ?
Because this browser view the session variable with a cookie !

In first page print value but not working in another page

check your cookies !

Steweb




Visit my web site !
www.steweb.net

lakshmi devi July 20th, 2006 04:33 AM

my browser is IE5.





All times are GMT -4. The time now is 10:23 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.