Jump to content

SetSessionVar - GetSessionVar


kporter.porter

Recommended Posts

Still trying to update this website from like 2000.

 

It looks like my sessions are not working correctly.  I get fatal errors on line 3 in this code:

<table cellspacing=0 cellpadding=3 border=0 width=70%>
<tr><td align=center><h3>Welcome, <u><b><?php= GetSessionVar("full_name") ?></b>  
</td>
</tr>
</table>

 

Call to undefined function GetSessionVar().

 

This is the error I get in my IDE.  The webpage just shows "Welcome _".

 

Combine this with the fact that I get an undefined index error for this code:

 

function _SessionCreate($SessionName)
{
$Db=new sql;
global $_SESSION_DATA;

$GLOBALS["$SessionName"]=md5 (microtime() . $_SERVER['REMOTE_ADDR']);
$Db->exec("insert into session (sid) values ('" . $GLOBALS["$SessionName"] . "')");        
$_SESSION_DATA["$SessionName"]=array();
SetCookie ("$SessionName", $GLOBALS["$SessionName"],0,"/");
return;         
}

 

The problem is with "$_SERVER['REMOTE_ADDR']);".  The REMOTE_ADDR being the problem.  Some of the pages using the session stuff worked before i upgraded to 5.2.4.  I am thinking all the code worked in 2000 but now is outdated after the upgrade.

 

If this is the case what verbs should I be using?  I have read where I can use isset to check the variable, but not sure how to write that around this multiple coded line.

 

Oh and what does the "space . space" do? 

 

Thanks again.

Link to comment
https://forums.phpfreaks.com/topic/73980-setsessionvar-getsessionvar/
Share on other sites

<table cellspacing=0 cellpadding=3 border=0 width=70%>
<tr><td align=center><h3>Welcome, <u><b><?php= $_SESSION['full_name'] ?></b>  
</td>
</tr>
</table>

 

This part is just a guess.

 

<?php

function _SessionCreate($SessionName)
{
$Db=new sql;
global $_SESSION_DATA;

$_SESSION["$SessionName"]=md5 (microtime() . $_SERVER['REMOTE_ADDR']);
$Db->exec("insert into session (sid) values ('" . $_SESSION["$SessionName"] . "')");        
$_SESSION_DATA["$SessionName"]=array();
SetCookie ("$SessionName", $_SESSION["$SessionName"],0,"/");
return;         
}

?>

 

I'm not really sure where your getting this from

$_SESSION_DATA

So I can't really help you with that one :)

Changed the first code from my first post to:

 

<table cellspacing=0 cellpadding=3 border=0 width=70%>
<tr><td align=center><h3>Welcome, <u><b><?php $name = GetSessionVar("full_name");
print "$name" ?></b>  
</td>
</tr>
</table>

 

Now it works and say's Welcome (the persons name).

 

Now on to the next problem.  I'll be back I am sure thanks for the help poco, I appreciate it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.