Connecting Tech Pros Worldwide Help | Site Map

session handling in javascript

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 17th, 2007, 12:50 PM
Newbie
 
Join Date: Jul 2007
Posts: 5
Default session handling in javascript

Hi everyone,
I wanted to know weather we can handle session using javascript.
Simply if i can test weather session is valid or not(i.e expired or still existing) does my work.
I was trying for it from past a week if anyone could help i would be happy.

Thanks and Regards,
Vidya Sagar Reddy.
Reply
  #2  
Old August 17th, 2007, 12:52 PM
kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
Default

Im going to move this to the Javascript Fourm. Have a nice day!

--
Kestrel
Reply
  #3  
Old August 17th, 2007, 12:54 PM
Newbie
 
Join Date: Jul 2007
Posts: 5
Default

Thanks and sorry i have posted at a wrong place
Reply
  #4  
Old August 17th, 2007, 01:00 PM
kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
Default

Dont worry too much about it. I get them all day long.
Reply
  #5  
Old August 17th, 2007, 01:20 PM
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Age: 21
Posts: 1,313
Default

Quote:
Originally Posted by vijay0456
Hi everyone,
I wanted to know weather we can handle session using javascript.
Simply if i can test weather session is valid or not(i.e expired or still existing) does my work.
I was trying for it from past a week if anyone could help i would be happy.

Thanks and Regards,
Vidya Sagar Reddy.
javascript doesn't do sessions, it does cookies.

well....if u use ajax then you can create session variables (using php, asp.net,...).

good luck
Reply
  #6  
Old August 17th, 2007, 01:28 PM
Newbie
 
Join Date: Jul 2007
Posts: 5
Default

Quote:
Originally Posted by epots9
javascript doesn't do sessions, it does cookies.

well....if u use ajax then you can create session variables (using php, asp.net,...).

good luck
@epots9

Thanks a lot buddy
I have done an example using ajax but for a big web page if we use ajax call for every hit is a costly work i think so i am trying for an alternative and less costlier. Can u suggest any alternative.

I am using only one page and in the same page i am playing with the javascript (like say hide and seek) but the session is only this which should be taken care .
Reply
  #7  
Old August 17th, 2007, 01:33 PM
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Age: 21
Posts: 1,313
Default

then just create cookies with javascript, i guess when the page loads make sure that the cookie(s) is(are) valid. cookies and sessions are pretty much the same, cookies are stored client-side and sessions are stored server-side.
Reply
  #8  
Old August 17th, 2007, 03:01 PM
Newbie
 
Join Date: Aug 2007
Posts: 14
Default

Quote:
Originally Posted by epots9
well....if u use ajax then you can create session variables (using php, asp.net,...).
would you be able to give an example of how i would use ajax to set an asp.net session variable?
Reply
  #9  
Old August 17th, 2007, 03:15 PM
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Age: 21
Posts: 1,313
Default

Quote:
Originally Posted by ahoyer
would you be able to give an example of how i would use ajax to set an asp.net session variable?
in your asp.net page just create a session variable as u normally would
Reply
  #10  
Old August 17th, 2007, 03:32 PM
Newbie
 
Join Date: Aug 2007
Posts: 14
Default

Quote:
Originally Posted by epots9
in your asp.net page just create a session variable as u normally would
Sorry, i should have been a little more specific, i know that in my asp.net behind code (say c#) i would just go like this in a method:

Expand|Select|Wrap|Line Numbers
  1. Session["varName"] = "some value";
what i was then wondering is how i could then use ajax or something in someway to call this from a javascript function. (i honestly dont know if this is possible, im pretty new to web dev, and i know little - nothing about ajax).

The reason why i wonder, is ive got an asp button, that when clicked i would like it to set the session variables, then open a new window (using javascript, window.open()) that will use those same session variables in some way.
Reply
  #11  
Old August 17th, 2007, 03:54 PM
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Age: 21
Posts: 1,313
Default

the javascript doesn't get it directly. in your asp.net page u do all validation of the session there, then if its valid or not the page returns true or false (return statement is added by the programmer, you, and it returns whatever u tell it). then back in the javascript it will receive the true or false and based on that do whatever it is you wanted it to do, it will do that.
Reply
  #12  
Old October 14th, 2008, 12:45 AM
Member
 
Join Date: Sep 2006
Posts: 72
Default

can javascript access session variable that define on vbcode in asp pages
Reply
  #13  
Old October 14th, 2008, 07:33 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,232
Default

If you return something back as output from your ASP page, then yes. For example, if you output the session variable in your ASP page, then it should be available to JavaScript in the XMLHttpObject's responseText property.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.