Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 01:40:56 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155538 Posts in 21712 Topics by 7737 Members
Latest Member: deanmacullam
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: using $_SESSION['USERNAME']  (Read 653 times)
ande159

Offline Offline

Posts: 7


« on: December 09, 2010, 08:08:21 PM »

Greetings All,

I'm trying to write a php script that will allow a user to update some information in a database.  Instead of writing it directly in the WB code editor, I would prefer to write it in a separate file then include(' '); my file within the WB code module.  However, I've run into a problem accessing the $_SESSION['USERNAME'] variable which I'm going to use to ascertain database access priviledges.  It seems to get forgotten somewhere between WB and my script.

If I do this within the WB code editor, it works
Code:
echo "<p>Hello: ".$_SESSION['USERNAME'];

However, it doesn't work if I enter this within the WB code editor
Code:
include('scripts/updateUnitAlertRoster.php');
and my separate script contains this
Code:
<?php
session_start
();

echo 
"Hello: ".$_SESSION['USERNAME'];

?>

Can anyone point me in the right direction for accessing the $_SESSION variables?

Thanks,
Ande
Huntsville, AL
Logged
DarkViper
Development Team
*****
Offline Offline

Posts: 1253


« Reply #1 on: December 09, 2010, 08:20:54 PM »

in Backend use
Code:
<?php
  
global $admin;
  echo 
'<p>Hello: '.$admin->get_username().'</p>';
?>
in Frontend use
Code:
<?php
  
global $wb;
  echo 
'<p>Hello: '.$wb->get_username().'</p>';
?>

don't restart the session, it's already running
don't use te superglobal $_SESSION[] array. From WB 2.9.0.dev it's values can change mabe.

Logged

Anleitungen lesen und selber nachdenken ist anstrengend...  Da lass ich doch lieber andere für mich denken...

In 1984:  Nineteen Eighty-Four is a unrealistic utopia!!
In 2012:  Nineteen Eighty-Four is a little piece only of our reality!!
ande159

Offline Offline

Posts: 7


« Reply #2 on: December 09, 2010, 08:28:08 PM »

That didn't seem to work...

In my stand along .php file, which I have included'd in the WB code section, I tried
Code:
<?php
echo "Hello, is this working?<p>";
global 
$wb;
echo 
'<p>Hello: '.$wb->get_username().'</p>';
?>
and
Code:
<?php
echo "Hello, is this working?<p>";
  global 
$admin;
  echo 
'<p>Hello: '.$admin->get_username().'</p>';
?>

each time all I got was the "..is this working" message.

Other ideas?

Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!