Session variables and Javascript

Results 1 to 4 of 4

Thread: Session variables and Javascript

  1. #1
    rcashon Guest

    Default Session variables and Javascript

    I read Paradox&#039s information abt JS and I to am an avid javascripter! I have a question with respect to being able to set a session variable from javascript. How can I do this or is it not possible. I know I could create a form and send it to the server to set the variable, but is there a way to set one inside a js routine. I can read the variables using <BR>&#060;script language=javascript>&#060;!--<BR> var myData<BR> myData = &#060;%= session("sessionValueIwant")&#037;&#062;<BR>//--><BR>I have tried all the options I could think of, but can not get it to work.<BR>Thanks <BR>rcashon@olanmills.com<BR> <BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    35

    Default RE: Session variables and Javascript

    I honestly haven&#039t played with session variables very much, but from what I&#039ve been reading you aught to be able to set session variables in Javascript. Where and how are you trying to set the variables? The reason that I ask is that from what I&#039ve read setting session object properties and such should be as easy as setting server object properties.<BR>P.S. if you do figure this out please let me know, or write an article for 4guys, I&#039m sure that they&#039d love it. ( I know I would)

  3. #3
    Ian Stallings Guest

    Default RE: Session variables and Javascript

    you can set the session just like you can set other objects:<BR><BR>&#060;script language=javascript runat=server><BR><BR>Session("variable") = "whatever";<BR>varSession = Session("variable");<BR>response.write(varSession) ;<BR><BR>&#060;/script><BR><BR>this works. I&#039m finding that asp objects work basically the same<BR>as in VBscript. It&#039s the javascript syntax which confuses me<BR>sometimes :) (like the ; at the end of the lines)

  4. #4
    Mark Hoffman Guest

    Default RE: Session variables and Javascript

    I might be wrong, but I don&#039t think this can be done. (I *hope* I am wrong too!)<BR><BR>One of the previous posters showed how you can do it with server side Javascript, but I&#039m guessing what you want is how to do it with client side Javascript. The problem, as I see it, is that client side Javascript executes in the browser, whereas server side code Javascript or VBScript executes on the server *before* it is sent to the browser. Session variables are on the server side, so I don&#039t see any way of manipulating them on the client.<BR><BR>I feel pretty confident that I am right here, but if anyone knows how to manipulate Session variables with client side Javascript, I would love to hear from them.<BR><BR>Mark Hoffman<BR>D Animation Multimedia and Web Design<BR>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •