/    Sign up×
Community /Pin to ProfileBookmark

Problem parsing variables into sessions

I have set up a site where the user can register and login and that is all working correctly but I am having trouble parsing the session variable.

Here is the code

[code=php]
$_SESSION[‘username’] = Fred; // if I hard code it here and in functions.php it works but if I try to parse the username from the $username variable it won’t

eg

$_SESSION[‘username’] = $username doesn’t carry across

[/code]

The session start function is called from the config.php file so runs on every page.

What am I missing???

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SheldonJun 18.2006 — well a variable cant have spaces for one

try
[code=php]
$_SESSION['username'] = "Fred";

//or
$_SESSION['username'] = $_POST['username'];

//if thats still doesnt poputlate the session, check to see it the var is being set before hand

if(!isset($var){
//Fark that damn var isnt set
}else{
//good work jimmy has done it again
}
[/code]
×

Success!

Help @mangoes spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...