/    Sign up×
Community /Pin to ProfileBookmark

PHP Session HELP!!!

Hello again
I’m new to php just know the basics and i’m having a problem with session variables

whats happening is i’m using a commenting program from GentleSource which is working great the only problem is that it produces its own session variables
and well i’m carring session varibles from page to page starting from the login

login
session_start();
$_session[‘….’] = $…..;

other pages
session_start();
$…. = $_session[‘…’];

now all my session variables are doing is carring over the user information from page to page to make sure someone is logged in or not

the problem i’m having is that there are 2 session_start so i get an ignore message for the other set of session variables and i was wonder is there a way i can add my session variables that are being asked on pages to the other set.

i’ve tried putting them in the commenting program but the code is way over my head so i cant do it that way . if any one could help me that would be awesome.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 20.2009 — Note that the session array name is $_SESSION and is case-sensitive. I don't know if that's your only issue, but it's the first fix I'd try. ?
Copy linkTweet thisAlerts:
@YokiestauthorNov 20.2009 — Sorry the sessions are in caps i should have typed it like that the problem i'm having is the comment script has a start_session(): in it and its included onto my pages and the pages have its own start_session(); and what ends up happening is the second session gets ignored
Copy linkTweet thisAlerts:
@NogDogNov 21.2009 — The second session_start() being ignored should not matter as far as the functionality. To get rid of the warning you can add an if condition in the second call:
[code=php]
<?php
if(session_id() == '')
{
session_start();
}
[/code]
Copy linkTweet thisAlerts:
@YokiestauthorNov 21.2009 — I did that but know i end up with Notice errors that i cant get rid of stating that the session variables are undefined
Copy linkTweet thisAlerts:
@NogDogNov 21.2009 — Can't help you with that without seeing code or greatly enhancing my ESP. If the page can be accessed without having those session variables set yet, you can use conditional logic there as well:
[code=php]
if(isset($_SESSION['foo']))
{
$foo = $_SESSION['foo'];
}
else
{
$foo = 'default value';
}
[/code]

That can be streamlined to:
[code=php]
$foo = (isset($_SESSION['foo'])) ? $_SESSION['foo'] : 'default value';
[/code]
×

Success!

Help @Yokiest 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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