I am having issues with using the $_SESSION[...] as it is timing out. My app would work if I could do something like the following: <?php // This value may come from a database, or a $_REQUEST variable already $itemVal = "Value Alpha"; // Set a link to call the new page with the $_REQUEST variable set for ?item echo "<a href='newPage.php?item=".$itemVal."'>Go to new page</a>"; ?> PHP: However, this does not seem to work as the ?item value is not showing up on the newPage.php being called. What is the proper way to set a request variable for the target page?
To past variables between pages, you can use the POST or the GET method. In your example, you are using the GET method. use the phpinfo(); function on the newPage.php to see if you variables are passed. you should do some reading on the 'GET' and 'POST' method from the php.net site. It will be helpful.
In terms of using the session variable, I just wanted to verify that you have session_start(); PHP: at the top of your page. Without it, you can't pass session data using the session superglobal variable. In terms of using the second example you provided, I wonder if having a space between the two words stored in the $itemVal variable is causing the issue. When you click the link created from echo "<a href='newPage.php?item=".$itemVal."'>Go to new page</a>"; PHP: what does the URL actually look like on the next page? It should look something like http://www.domain.com/newPage.php?item=Value%20Alpha if not, try changing the value of your variable to something like this: $itemVal = "Value_Alpha" PHP: To get the value passed through the URL, you would want something like $getValue = $_GET['item']; PHP: That should set your $getValue variable with the value passed from "item" in the URL.
On the $_SESSION attempt, I was setting the session_start() at the top of the script...but it seems to be timing out after about 10 secs. Is there any way to make the session "never" time out? If so, then that may be my solution. The %20 should show up by the browser, so I don't think the under-score should be an issue. The value will be coming from a database anyway, so really should not be altering it. The way you showed the address is correct, that is what I "want" to show, however, there is nothing after the equals " = " sign...so there is no request value for the item.
You understand that this variable you are using has nothing to do with sessions here, unless you assign it to a session variable. <?php session_start(); // request is get and post and cookie global not session $_SESSION['somevalue'] = (isset($_REQUEST['somevalue']) ) ? $_REQUEST['somevalue'] : 'defaultvalue'; // now make the link with the session var PHP: