Skip to main content
Inspiring
May 20, 2009
Answered

session variables

  • May 20, 2009
  • 2 replies
  • 784 views

I want to create and pass session variables. The adobe document at  http://kb2.adobe.com/cps/165/tn_16563.html tells me to use

<?php
session_start();
session_register("sessFirstName");
$sessFirstName = $HTTP_POST_VARS['txtFirstName'];
?>

When I test, the response is that this script relies on a side effect of php 4xx and that it requires register_globals to be on, which I don't want.

The warning disappeared but then when I went to log in again with new values, the values on the recipient page were the old ones. So, I inserted a Logout and of course that took me to the loggedout. page but didn't erase the values, which, when I logged in again, were still the old ones. I know that by default the values remain for 20 minutes, but shouldn't they change when a new log in with new values is attempted?

Does anyone have the updated version of the php snippet from above?  Thanks.

This topic has been closed for replies.
Correct answer DwFAQ

BrianNardone wrote:

I want to create and pass session variables. The adobe document at  http://kb2.adobe.com/cps/165/tn_16563.html

tells me to use

<?php
session_start();
session_register("sessFirstName");
$sessFirstName = $HTTP_POST_VARS['txtFirstName'];
?>

Does anyone have the updated version of the php snippet from above?  Thanks.

Look Here

<?php
session_start();
$_SESSION['firstName'] = 'whatever';
?>

2 replies

David_Powers
Inspiring
May 21, 2009

Duplicate thread started. This thread now locked and assumed answered.

DwFAQ
DwFAQCorrect answer
Participating Frequently
May 20, 2009

BrianNardone wrote:

I want to create and pass session variables. The adobe document at  http://kb2.adobe.com/cps/165/tn_16563.html

tells me to use

<?php
session_start();
session_register("sessFirstName");
$sessFirstName = $HTTP_POST_VARS['txtFirstName'];
?>

Does anyone have the updated version of the php snippet from above?  Thanks.

Look Here

<?php
session_start();
$_SESSION['firstName'] = 'whatever';
?>
Inspiring
May 20, 2009

Page 1 has a login form with six fields.

The textfields in the form are username and password.

The hidden fields in the form are: nationality, country, studylang, primelang and their values will be set by incoming URL paramenters from a prior page or hard coded in.

I am trying to create session variables of the four hidden fields to avoid having to deploy recordsets on every subsequent page.

After the Login button is pushed, I want these four hidden form fields, nationality, country, studylang and primelang, and their values, to pass, as Session Variables,  to the next page and to subsequently be available to all pages so I can use them in links to other pages and in <img src="folderX/SessionVariableValue/book1.php. > Make sense?

Every supporting page seems to work:
On the login page, the $MM_redirectLoginSuccess = "yadayada.php"; works fine.

I've used  <?php if ($_POST) {print_r($_POST);} ?> to check the post array and it is working correctly for all the fields.

I have created the bindings for the four Session Variables with the same words: nationality, country, studylang, primelang and deployed them into the recipient page:

<?php echo $_SESSION['primelang']; ?>

<?php echo $_SESSION['country']; ?>

<?php echo $_SESSION['nationality']; ?>

<?php echo $_SESSION['studylang']; ?>

QUESTION: How do I get the form elements for nationality, country, studylang, primelang from the Post array to input into the head code on the  recipient page? I have this deployed in the head code, but the gentleman who offered to help previously didn't inform me how to get the hidden field values into the 'whatever'.

<?php session_start();
$_SESSION['nationality'] = 'whatever';
$_SESSION['studylang'] = 'whatever';
$_SESSION['primelang'] = 'whatever';
$_SESSION['country'] = 'whatever';

?>

What is the magic, missing link?

I tried using Form Variables to pick up the values, but PHP didn't like it or I messed it up.  I cannot find one COMPLETE explanation of how to create, pass, retrieve and deploy Session Variables anywhere on the web. Thank you for your help.

David_Powers
Inspiring
May 21, 2009

This question has been answered here. Please do not post the same question twice in different threads.