Printing session variable values in includes?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rebajas
Forum Newbie
Posts: 16
Joined: Tue Aug 20, 2002 9:35 am
Location: http://www.rebajas.co.uk/

Printing session variable values in includes?

Post by Rebajas »

Allo,

I have a simple login on my site that works fine - however, one of the requirements of the site is to have the users nickname in the menu linked to their profile. This menu is in an include and although it changes depending on whether the user is logged in, i can't seem to print the variable:

Code: Select all

if (session_is_registered("loggedIn")) {
			?>	<h5 class="title">signed in</h5>
			you are signed in as: <span class="bold"><a href="/profiles.php?searchBy=nickName&searchKeyword=<?php print $sessionNickname; ?>"><?php print $sessionNickname; ?></a></span>
			<input type="button" class="formSubmit" value="log out" />
			<?php
		&#125;
At the top of the include i have:

Code: Select all

<?php

session_start();
Any help appreciated,

Tony.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

after you read Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+ try $_SESSION['<variable name>']
Post Reply