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

$_SESSION Values Issue

Guest
Apr 25, 2007 Apr 25, 2007
First, let me state that i am a beginner when it comes to PHP, so please forgive me. I have read the posts that i have seen on the board regarding this issue and have yet been able to fix my issue.

I am using a simple form that is accessing a mySQL database for a sign-in. I am using the code that is generated by Dreamweaver Server Behaviors. The name is being looked up and it is returning to the "successful page." I have checked both pages invoved and have made sure that the following is called prior to the doc type declaration:

<?php //initialize the session
if (!isset($_SESSION)) {
session_start();
}
?>
...
...
<!DOCTYPE>

Now, in addition to this, i have ensured that the temp directory is defined in the php.ini file. With both of these things done, does anyone have any suggestions?

I am using the Dreamweaver CS3

Thanks
TOPICS
Server side applications
671
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 ,
Apr 25, 2007 Apr 25, 2007
dwb67 wrote:
> First, let me state that i am a beginner when it comes to PHP, so please
> forgive me. I have read the posts that i have seen on the board regarding this
> issue and have yet been able to fix my issue.

Perhaps if you say what the issue is, others might be able to help. If
it's returning you to the successful page, what's the problem?

--
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
Guest
Apr 25, 2007 Apr 25, 2007
I am loosing the $_SESSION values. I cannot access MM_Username once the user is signed in and the values have been set. I have tried to return to the current page and to another page. Both cannot display the $_SESSION['MM_Username'] value.
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
Guest
Apr 25, 2007 Apr 25, 2007
I also would like to add, that i can set a $_SESSION variable and share it across pages. So, this would indicate that $_SESSION variables are working. I would now say that there must be an issue with the way that the "Log In User" Server Behavior is functioning. For now i understand that these variables must be getting reset or cleared.

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 ,
Apr 25, 2007 Apr 25, 2007
dwb67 wrote:
> I also would like to add, that i can set a $_SESSION variable and share it
> across pages. So, this would indicate that $_SESSION variables are working. I
> would now say that there must be an issue with the way that the "Log In User"
> Server Behavior is functioning. For now i understand that these variables must
> be getting reset or cleared.

The Log In User server behavior in CS3 works just fine. If you're able
to use other session variables, it doesn't sound as though anything is
wrong with your setup. Perhaps you could post a sample of the code
that's not working.

--
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
Guest
Apr 25, 2007 Apr 25, 2007
I have not modifed the code. This is the code that has been generated by the CS3 server behavior:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_SoSMain, $SoSMain);
$query_rs_pagequote = "SELECT * FROM quotes ORDER BY quoteid ASC";
$rs_pagequote = mysql_query($query_rs_pagequote, $SoSMain) or die(mysql_error());
$row_rs_pagequote = mysql_fetch_assoc($rs_pagequote);
$totalRows_rs_pagequote = mysql_num_rows($rs_pagequote);

$colname_rs_currentpage = "-1";
if (isset($_SESSION['CurrentPage'])) {
$colname_rs_currentpage = $_SESSION['CurrentPage'];
}
mysql_select_db($database_SoSMain, $SoSMain);
$query_rs_currentpage = sprintf("SELECT Name, pageurl FROM pageinfo WHERE pageurl = %s", GetSQLValueString($colname_rs_currentpage, "text"));
$rs_currentpage = mysql_query($query_rs_currentpage, $SoSMain) or die(mysql_error());
$row_rs_currentpage = mysql_fetch_assoc($rs_currentpage);
$totalRows_rs_currentpage = mysql_num_rows($rs_currentpage);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['Name'])) {
$loginUsername=$_POST['Name'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "siterankid";
$MM_redirectLoginSuccess = "default.php";
$MM_redirectLoginFailed = "badsignin.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_SoSMain, $SoSMain);

$LoginRS__query=sprintf("SELECT name, password, siterankid FROM members WHERE name=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $SoSMain) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

$loginStrGroup = mysql_result($LoginRS,0,'siterankid');

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

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 ,
Apr 25, 2007 Apr 25, 2007
dwb67 wrote:
> I have not modifed the code. This is the code that has been generated by the
> CS3 server behavior:

It's not clear what you're trying to do, but the obvious problem with
that code is that the Log In User server behavior is below the first
call to a session variable. The call to session_start() must come before
using an session variables.

The Log In User server behavior is designed as a login routine. It's not
designed to be mixed arbitrarily with other session code on the same page.


--
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
Guest
Apr 25, 2007 Apr 25, 2007
I didnt see that noted in any documentation. and it works just fine that way with ASP.
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 ,
Apr 25, 2007 Apr 25, 2007
dwb67 wrote:
> I didnt see that noted in any documentation. and it works just fine that way with ASP.

PHP is not ASP. Before you can access any session variables, you must
call session_start().

http://www.php.net/manual/en/ref.session.php

Scroll down to look at some of the practical examples.

--
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
Guest
Apr 25, 2007 Apr 25, 2007
LATEST
Well, i guess i just dont get it. i have removed ALL other $_SESSION variables from the page and have just the sign in server behavior and it still doesnt work. I just am not getting it. I have the session_start(), and i still cannot access the variables MM_Username when the signin process is done.
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