Forum Moderators: coopster
I do have a working script that grabs a variable coming from a referrer URL. If I simply redirect it right away to my partner (no my own site except for redirection), it works fine.
Now I wonder about having that variable KEPT while people browse through my site, and forward it out once they click onto outgoing link.
From what I found, session or cookie could be options, not sure if they would be ONLY options, no argument, just curious.
Anyhow, I am aware of the fact that I have to grab my incoming variable first, so my existing code will be there. Then I need to either store it or carry around while user browses through the site, just so I have it "remembered" so I can forward it out.
My vision is that I would:
Three questions:
It’s one variable only, called $variable.
Thanks
However a brief answer to your questions -
1) The $_SESSION array works like any other. If you add elements to it then they remain in there, until get rid of them. So as long as there is a page reload and information sent through to the server even though everything is on one page you will be able to add, remove or manipulate the $_SESSION array at each page load.
2) You need to call session_start to open a session. You may well want to have a look at articles about session hijacking, as this is where people use already opened sessions. So in short you are better off starting a new session each time a person comes back. If you want information preserved from visit to visit then store it a a cookie on there computer, not in a persistent session.
3) When the session is started php gives a unique identifier to each session, the session id. This can either be stored as a cookie or passed along in the url. Using the url is not a good idea, as there are a lot more security problems with this. So this id is used to link the $_SESSION array to an individual (well hopefully an individual, but that is why you need to look up session hijacking).