session: how to call value

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
chxxangie
Forum Newbie
Posts: 12
Joined: Wed Sep 19, 2007 10:00 pm

session: how to call value

Post by chxxangie »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[u]page A[/u]

Code: Select all

session_start(); 
session_register('active'); 
session_register('username');
page B

Code: Select all

session_start();
if(session_is_registered('active')){ 
<div id="Layer4" style="position:absolute; left:798px; top:91px; width:176px; height:18px; z-index:7;">Welcome, [color=red]......called username value........ [/color]</div>
}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]1.[/b] Select the correct board for your query. Take some time to read the guidelines in the sticky topic.[/quote]
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post by mrkite »

Code: Select all

echo $_SESSION['username'];
User avatar
maliskoleather
Forum Contributor
Posts: 155
Joined: Tue May 15, 2007 2:19 am
Contact:

Post by maliskoleather »

session_register has been depreciated.
use:

Code: Select all

session_start();

//set the variable
$_SESSION['foo'] = 'bar';

//call the variable
echo $_SESSION['foo'];
nhammond
Forum Newbie
Posts: 14
Joined: Mon Dec 18, 2006 11:35 am

Post by nhammond »

and if you want to check if it is set jsut use

Code: Select all

if (isset($_SESSION['var_name'])){}
Post Reply