Skip to main content
Known Participant
September 11, 2006
Question

Set up a Session Variable

  • September 11, 2006
  • 5 replies
  • 588 views
Hi,

How to setup a session variable of User id in PHP in Dreamweaver Style. Is it possible to assign the session variable value equal to user id from the recordset......if yes i need the procedure. Thanks in advance.
This topic has been closed for replies.

5 replies

Inspiring
September 13, 2006
prashi123 wrote:
> <?php
> session_start();
>
> $_SESSION['user_id'] = $row_login['user_id'];
> ?>
>
> where login is my recordset name....but when i preview it in the browser i get
> follwing error message
> "undefined variable : $row_login"

You need to put the following line *after* the recordset code:

$_SESSION['user_id'] = $row_login['user_id'];

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Angell EYE
Inspiring
September 13, 2006
You can bind session variables to the Bindings panel for drag-and-drop capabilities by clicking the + in the Bindings panel and selecting Session Variable. Type in the name of the session variable you created and it will place it in the Bindings panel just like recordset data or form data.
prashi123Author
Known Participant
September 13, 2006
Anyone there.....
Angell EYE
Inspiring
September 13, 2006
I don't know PHP but I can show you how I do this with ASP. If i have a recordset named rsUsers which contains a userName field and I want to store it in a session variable called userName I'd use the following:

Session("userName") = rsUsers("userName")

Then when I want to display that to the page or use it in any way I use:

<%=Session("userName")%>
prashi123Author
Known Participant
September 13, 2006
Hi,
I tried with the follwoing code

<?php
session_start();

$_SESSION['user_id'] = $row_login['user_id'];
?>

where login is my recordset name....but when i preview it in the browser i get follwing error message
"undefined variable : $row_login"

Please help me with this....
Inspiring
September 11, 2006
prashi123 wrote:
> How to setup a session variable of User id in PHP in Dreamweaver Style. Is it
> possible to assign the session variable value equal to user id from the
> recordset......if yes i need the procedure.

There is no "Dreamweaver style" for setting up a session variable. You
do it in exactly the same way as for any PHP page. Put this at the
beginning of the page:

session_start();

Retrieve the value that you want from the recordset and assign it to a
session variable like this:

$_SESSION['user_id'] = $row_recordsetName['user_id'];

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/