954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can you keep a variable the same in each webpage of a website?

Say in index.html you set variable x to be 5.
You navigate to a different page, lets say pageone.html.
How can you keep x to 5?
And if you change x to 3 on pageone.html, how can you keep it to 3 on pagetwo.html? (the whole website also, every webpage)
Is this possible in javascript or do you need php?

Will give more explanations if needed.
thanks

edit: i did try googling, but i really didnt know how to phrase it for a search so it kinda messed up.

edit 2:
think umm.. like a shop website, you add something to your basket, the basket will say 1 item and will stay like that on every webpage.

FriXionX
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Javascript can read & write information to both cookies and a special client side storage area if a large amount of stuff needs to be stored. However it is not very secure as the visitor can ammend any data stored in their browser.

PHP does this sort of thing a lot better using session variables, plenty of good tuts out there.

Sogo7
Newbie Poster
23 posts since May 2011
Reputation Points: 10
Solved Threads: 5
 

Javascript can read & write information to both cookies and a special client side storage area if a large amount of stuff needs to be stored. However it is not very secure as the visitor can ammend any data stored in their browser.

PHP does this sort of thing a lot better using session variables, plenty of good tuts out there.


It's okay, this is just for college. We were only supposed to do a simple webpage (not even including css) but i've gone way overboard trying to get a distinction. Anything will do at this point. I don't really want to use php right now really, so do you think javascript would be okay?

FriXionX
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This may be of interest.

Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,682 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

This may be of interest.

Airshow

Thanks for that. +1

FriXionX
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You