Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1050091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:43:07+00:00 2026-05-16T16:43:07+00:00

Let’s say I have a page that refers to a .js file. In that

  • 0

Let’s say I have a page that refers to a .js file. In that file I have the following code that sets the value of a variable:

var foo;

function bar()
    {
    foo = //some value generated by some type of user input
    }

bar();

Now I’d like to be able to navigate to another page that refers to the same script, and have this variable retain the value set by bar(). What’s the best way to transport the value of this variable, assuming the script will be running anew once I arrive on the next page?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:43:08+00:00Added an answer on May 16, 2026 at 4:43 pm

    You can use cookies.

    Cookies were originally invented by
    Netscape to give ‘memory’ to web
    servers and browsers. The HTTP
    protocol, which arranges for the
    transfer of web pages to your browser
    and browser requests for pages to
    servers, is state-less, which means
    that once the server has sent a page
    to a browser requesting it, it doesn’t
    remember a thing about it. So if you
    come to the same web page a second,
    third, hundredth or millionth time,
    the server once again considers it the
    very first time you ever came there.

    This can be annoying in a number of
    ways. The server cannot remember if
    you identified yourself when you want
    to access protected pages, it cannot
    remember your user preferences, it
    cannot remember anything. As soon as
    personalization was invented, this
    became a major problem.

    Cookies were invented to solve this
    problem. There are other ways to solve
    it, but cookies are easy to maintain
    and very versatile.

    See: http://www.quirksmode.org/js/cookies.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say you have a method that expects a numerical value as an argument.
Let me explain best with an example. Say you have node class that can
Let's say that I have a SQLite database that I create in a separate
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have multiple requirements for a password. The first is that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.