Advertisement

04.16.2008 at 01:27PM PDT, ID: 23328768
[x]
Attachment Details

set session variable without FORM, retain variable after refresh independent of whats in the address bar

Asked by mattpiercey in PHP Scripting Language, Web Languages/Standards, MySQL

Tags: php, Firefox 2.0

If in your browser address bar you take away everything after the question mark and press enter, the page will refresh without the session variable set.  The problem is that the session variable is dependent on what is in the address bar.  

Example:
www.mypage.com/lets_change_session_variable.php?does_php_work=no

will correctly set the session varaible, but when you delete everything after the question mark and press enter, the page will refresh without the session variable set.

 Was hoping to not have to use a form to set a session variable, here is the code I have, yet the variable seems to not get set.  Must I use a form?  Is there any way to avoid using a form to set a session variable in php?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
<?php
session_start();
; ?>
<html><body><?php
//SNIPPET 1
//this file is called lets_change_session_variable.php
 
$does_php_work = $_GET['does_php_work'];
 
if ($does_php_work == "yes") {
                $_SESSION['does_php_work']                      = "yes";
                echo "yes, it works";
                echo "<a href='lets_change_session_variable.php?does_php_work=no'>click to change variable to no</a>";
}
else
{
                $_SESSION['does_php_work']                      = "no";
                echo "no, it does not work";
                echo "<a href='lets_change_session_variable.php?does_php_work=yes'>click to change variable to yes</a>";
}
; ?>
[+][-]04.16.2008 at 01:54PM PDT, ID: 21371861

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:07AM PDT, ID: 21432995

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:25AM PDT, ID: 21433150

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:10PM PDT, ID: 21442438

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:17PM PDT, ID: 21442480

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:28PM PDT, ID: 21442567

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:30PM PDT, ID: 21442581

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:31PM PDT, ID: 21442585

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:35PM PDT, ID: 21442614

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:47PM PDT, ID: 21442695

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:50PM PDT, ID: 21442720

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Web Languages/Standards, MySQL
Tags: php, Firefox 2.0
Sign Up Now!
Solution Provided By: rowejd
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.25.2008 at 12:51PM PDT, ID: 21442731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:57PM PDT, ID: 21442769

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 01:00PM PDT, ID: 21442778

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 01:17PM PDT, ID: 21442900

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628