WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: david doc watson on February 20, 2011, 02:54:21 PM

Title: I am clearly incredibly dumb but...
Post by: david doc watson on February 20, 2011, 02:54:21 PM
I want to create a simple Droplet and can't work out the Syntax.

I simply want to show the logged in user's name on the page. I've worked out that the variable I need is:
$_SESSION['USERNAME'].  But what exactly to I put into the drplete box?

return $_SESSION['USERNAME']

or something else.

Thanks
Title: Re: I am clearly incredibly dumb but...
Post by: NorHei on February 20, 2011, 04:42:53 PM
Hmm, if variable is the right one i guess you forgot the ";" at the end  :-D

Code: [Select]
return $_SESSION['USERNAME'];
I would extend this a little bit.
Code: [Select]
if (isset($_SESSION['USERNAME'])) {return $_SESSION['USERNAME'];}
else {return 'Guest';}


As a session is only created if a user is logged in, you wil get an error messabe if the variable does not exist.
Title: Re: I am clearly incredibly dumb but...
Post by: david doc watson on February 21, 2011, 10:13:34 AM
Genius,

Thank you so much, the semi-colon did the trick.

Thanks for the idea about the non-logged in user - in this case the page is within the 'client area' but your code will be really useful in the future.

Thanks