Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Storing Recordset in Session Variable

New Here ,
Jun 29, 2007 Jun 29, 2007
How do you store information from a recordset in a session variable?
TOPICS
Server side applications
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 30, 2007 Jun 30, 2007
Create your recordset and then use code like this to set the session.

Session("mysession") =(rsexample.Fields.Item("ColName").Value)


After you do that, you can create a binding in the Data Bindings window by
using the + and choosing Session Variable and naming it mysession (as in the
example). That will create the binding that you can use whereever you wish
on your page to get the value to show up.

Note .. the above is ASP .. you didn't specify your server model.


--
Nancy Gill
Adobe Community Expert
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference, DMX 2004: A Beginner's Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2007 Jun 30, 2007
I'm using PHP.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 30, 2007 Jun 30, 2007
PHP sessions are more complicated. You'll have to make sure the host hasn't
disabled them on the server for starters. You also have to start and
register sessions like this:

<?php session_start(); // This connects to the existing session
session_register ("name"); // Create a session variable called name
session_register ("job"); // Create a session variable called job
$HTTP_SESSION_VARS ["name"] = $name; // Set name = form variable $name
$HTTP_SESSION_VARS ["job"] = $job; // Set job = form variable $job
?>



--
Nancy Gill
Adobe Community Expert
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference, DMX 2004: A Beginner's Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 30, 2007 Jun 30, 2007
Nancy - Adobe Comm. Expert wrote:
> PHP sessions are more complicated.

No, they're not.

> You also have to start and
> register sessions like this:
>
> <?php session_start(); // This connects to the existing session
> session_register ("name"); // Create a session variable called name
> session_register ("job"); // Create a session variable called job
> $HTTP_SESSION_VARS ["name"] = $name; // Set name = form variable $name
> $HTTP_SESSION_VARS ["job"] = $job; // Set job = form variable $job
> ?>

No, no, no!!! That is deprecated code that will break on most modern
servers. This is the correct way to write the above example.

<?php
session_start();
$_SESSION['name'] = $name;
$_SESSION['job'] = $job;
?>

If you're using form variables sent by the POST method, then it should
be this:

<?php
session_start();
$_SESSION['name'] = $_POST['name'];
$_SESSION['job'] = $_POST['job'];
?>

For more information about PHP sessions:
http://www.php.net/manual/en/ref.session.php

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2007 Jun 30, 2007
But I'm dealing with putting the information from a recordset into a session variable. I don't know what form variables are. Also, why do I need TWO session variables? Why can't I just use one for the recordset field I'm storing? And how do I know if I'm using POST?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 30, 2007 Jun 30, 2007
Gabe the Animator wrote:
> But I'm dealing with putting the information from a recordset into a session
> variable. I don't know what form variables are. Also, why do I need TWO session
> variables? Why can't I just use one for the recordset field I'm storing?

It sounds as though you are shooting completely blind. The two variables
are examples. You can have as many or as few session variables as you
want. To create session variables in PHP there are two requirements:

1. You must start the page with this

session_start();

2. To create a session variable, do this:

$_SESSION['variable_name'] = variable_value;

Replace variable_name with the name that you want to use for the
variable. Replace variable_value with whatever you want to store.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2007 Jul 01, 2007
And now you know why I don't really like PHP. :)
Hasn't PHP changed the way you do this several times during its evolution ..
so what version of PHP is on the server would make a difference?

Thanks for the link,
Nancy

"David Powers" <david@example.com> wrote in message
news:f666uj$mst$1@forums.macromedia.com...
> Nancy - Adobe Comm. Expert wrote:
>> PHP sessions are more complicated.
>
> No, they're not.
>
>> You also have to start and register sessions like this:
>>
>> <?php session_start(); // This connects to the existing session
>> session_register ("name"); // Create a session variable called name
>> session_register ("job"); // Create a session variable called job
>> $HTTP_SESSION_VARS ["name"] = $name; // Set name = form variable
>> $name
>> $HTTP_SESSION_VARS ["job"] = $job; // Set job = form variable $job
>> ?>
>
> No, no, no!!! That is deprecated code that will break on most modern
> servers. This is the correct way to write the above example.
>
> <?php
> session_start();
> $_SESSION['name'] = $name;
> $_SESSION['job'] = $job;
> ?>
>
> If you're using form variables sent by the POST method, then it should be
> this:
>
> <?php
> session_start();
> $_SESSION['name'] = $_POST['name'];
> $_SESSION['job'] = $_POST['job'];
> ?>
>
> For more information about PHP sessions:
> http://www.php.net/manual/en/ref.session.php
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2007 Jul 01, 2007
Nancy - Adobe Comm. Expert wrote:
> And now you know why I don't really like PHP. :)
> Hasn't PHP changed the way you do this several times during its evolution ..
> so what version of PHP is on the server would make a difference?

Not several times, no. Sessions were first introduced in PHP 4.0.0 (May
2000) and used the session_register() syntax. The $_SESSION syntax was
introduced in PHP 4.1.0 (December 2001).

The session_register() syntax doesn't work if register_globals is off.
This has been the default setting since PHP 4.2.0 (April 2002), although
some ill-advised hosting companies turn it back on. The register_globals
directive, if turned on, automatically creates variables derived from
the name of input elements. So, for example, the value of a text field
called "email" is automatically stored in a variable called $email. Very
convenient, but a massive security hole. PHP 6 will remove
register_globals permanently.

So, yes, session creation changed in the early days, but the recommended
method (using the $_SESSION syntax) has remained stable for the past
five years.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2007 Jul 09, 2007
Thanks, everybody, for all the help.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2007 Jul 09, 2007
Actually, now when I test it out, I get "Resource id #3orgidcopy" (my recordset field is called orgidcopy and appears as" Recordset1.orgidcopy") instead of the data from the recordset. What's going on?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2007 Jul 09, 2007
Maybe my problem is "echoing" the Session Variable??
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2007 Jul 10, 2007
anyone?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2007 Jul 12, 2007
?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2007 Jul 14, 2007
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 19, 2007 Jul 19, 2007
LATEST
.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines