CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    160

    saving variables between stages

    a lot of times i have to save certain variables in ajax/javascript. What is the best practice way to save such variables....

    right now i save them as hidden form fields and assign them an id and access them later... but im wondering if this is the right way to do it.

    i do know another method of saving it is using cookies... if there are other i donot know... so plz fill in wat you think is the way to store variables for use by jquery/javascript

    i know this is not exactly server side but it has ajax involved and i wasnt getting any response from the ajax forum so thought i would paste here.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: saving variables between stages

    Unless you want a server-side solution, I'm going to move this to client-side scripting.

    As for your problem, client-side storage is very limited. As you've already mentioned, you have <input> and cookies. Other than that, you will have to go server-side. I'm going to already assume that the information your passing is not volatile. If it needs security...then ALWAYS use server-side storage methods.

    So, with that in mind, as long as your information is not large, there's no reason why you shouldn't just use forms. If you're passing this across multiple pages, you will want to look into cookies. Or, to keep your HTML output to a minimum, sometimes you may want to use cookies as well.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2009
    Posts
    160

    Re: saving variables between stages

    Quote Originally Posted by PeejAvery View Post
    Unless you want a server-side solution, I'm going to move this to client-side scripting.

    As for your problem, client-side storage is very limited. As you've already mentioned, you have <input> and cookies. Other than that, you will have to go server-side. I'm going to already assume that the information your passing is not volatile. If it needs security...then ALWAYS use server-side storage methods.

    So, with that in mind, as long as your information is not large, there's no reason why you shouldn't just use forms. If you're passing this across multiple pages, you will want to look into cookies. Or, to keep your HTML output to a minimum, sometimes you may want to use cookies as well.
    perfect, makes sense.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: saving variables between stages

    [ moved thread ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured