Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Passing variables from one page to another


  • From: mwarden at gmail.com (Matt Warden)
  • Subject: [Javascript] Passing variables from one page to another
  • Date: Wed Dec 27 12:42:24 2006

On 12/27/06, tedd <tedd@xxxxxxxxxxxx> wrote:
> There are several ways that I can pass variables between pages in
> php, such as to use sessions or cookies, but those are required
> because the operations are server-side and thus stateless.

There is nothing about server-side that makes it stateless. The
interaction between client and server is what is stateless, thus
things are stateless from the perspective of the client as well (it
must maintain state itself).

> What I want is a way for javascript (client-side) to pass variables
> from one web page to another. It seems to me that a client-side
> operation should be able to provide for this.
>
> For example, if I declare var a=1; in the index page (init on load),
> then how can I find out what it's value is in the contact page? Or is
> my thinking here too fuzzy?

You're looking at cookies or sessions. Either set the cookie directly
via JS, or use a trick like:

var a = 1;
(new Image()).src = '/myscript.php?a='+ a;

Then myscript.php can set the cookie or use session.

-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.