473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Session ID Problem

I use a Session ID to remember a user that's logged in on my site,
which works pretty well for the most part, because index.html sends
them to a page (index0.php) that starts the session and then sends
them on to index.php. However, this means that if someone goes
straight to one of the pages on my site that requires a Session ID to
allow them access to something, the page returns error strings at the
top, although it does proceed to display the rest of the page (so at
least it kind of works). I've tried just putting the session_start();
code right into the same page, but it then returns an error and won't
display the page at all. Is there any good way to start a session
within the same page (HTML or PHP) that I plan to locate the variable?
And just out out of curiousity, why doesn't it work to simply place
the session_start(); code earlier in the code than the code to catch
the session variable?

Thanks in advance,

Jonathan
Jul 17 '05 #1
4 3305
th***************@yahoo.com (Jonathan) wrote in message news:<67**************************@posting.google. com>...
least it kind of works). I've tried just putting the session_start();
code right into the same page, but it then returns an error and won't
display the page at all. Is there any good way to start a session
Thanks in advance,

Jonathan


It returns "an error"! _What_ error does it return?
Jul 17 '05 #2
Well, the easiest way is to turn on auto-session.

Calling session_start() doesn't cause any session variables to become
defined. Presumably that's the warning message that you're getting.

Uzytkownik "Jonathan" <th***************@yahoo.com> napisal w wiadomosci
news:67**************************@posting.google.c om...
I use a Session ID to remember a user that's logged in on my site,
which works pretty well for the most part, because index.html sends
them to a page (index0.php) that starts the session and then sends
them on to index.php. However, this means that if someone goes
straight to one of the pages on my site that requires a Session ID to
allow them access to something, the page returns error strings at the
top, although it does proceed to display the rest of the page (so at
least it kind of works). I've tried just putting the session_start();
code right into the same page, but it then returns an error and won't
display the page at all. Is there any good way to start a session
within the same page (HTML or PHP) that I plan to locate the variable?
And just out out of curiousity, why doesn't it work to simply place
the session_start(); code earlier in the code than the code to catch
the session variable?

Thanks in advance,

Jonathan

Jul 17 '05 #3
th***************@yahoo.com (Jonathan) wrote in message news:<67**************************@posting.google. com>...

First of all, avoid using an .html file because every time it is
called, the session for the user calling that page is lost.
Use only .php files and put session_start() early in the script,
before any output is produced because the session must be started
before the headers are sent (when producing any kind of output the
headers are automatically sent). Another possible cause of error while
using session_start() could arise if you are using windows and haven't
defined a directory for the sessions.

If you need any further help, please be a little more specific on you
script and the exact errors it produces.

Regards,

alpeb

I use a Session ID to remember a user that's logged in on my site,
which works pretty well for the most part, because index.html sends
them to a page (index0.php) that starts the session and then sends
them on to index.php. However, this means that if someone goes
straight to one of the pages on my site that requires a Session ID to
allow them access to something, the page returns error strings at the
top, although it does proceed to display the rest of the page (so at
least it kind of works). I've tried just putting the session_start();
code right into the same page, but it then returns an error and won't
display the page at all. Is there any good way to start a session
within the same page (HTML or PHP) that I plan to locate the variable?
And just out out of curiousity, why doesn't it work to simply place
the session_start(); code earlier in the code than the code to catch
the session variable?

Thanks in advance,

Jonathan

Jul 17 '05 #4
Jay
I had the same prob until i included this on each page.

<?
$memberid = $_SESSION['pp_userid'];

if (empty($memberid)) {
echo "<p><b>Unauthorised User</b></p>";
echo "Please click <a href=\"member.php\">here</a> to login";
die;
}
?>
"Jonathan" <th***************@yahoo.com> wrote in message
news:67**************************@posting.google.c om...
I use a Session ID to remember a user that's logged in on my site,
which works pretty well for the most part, because index.html sends
them to a page (index0.php) that starts the session and then sends
them on to index.php. However, this means that if someone goes
straight to one of the pages on my site that requires a Session ID to
allow them access to something, the page returns error strings at the
top, although it does proceed to display the rest of the page (so at
least it kind of works). I've tried just putting the session_start();
code right into the same page, but it then returns an error and won't
display the page at all. Is there any good way to start a session
within the same page (HTML or PHP) that I plan to locate the variable?
And just out out of curiousity, why doesn't it work to simply place
the session_start(); code earlier in the code than the code to catch
the session variable?

Thanks in advance,

Jonathan

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Billy Jacobs | last post by:
I am having a problem with my session variable being set to Null for no apparent reason. I am declaring it like the following when the user logs in. dim objUserInfo as new clsUserInfo 'Set...
1
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
5
by: Mark Rodrigues | last post by:
Hi Everyone, I have been fighting a problem for a while and I wonder if someone out there can help. This problem has been presented in a number of news postings previously but I am yet to see a...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
5
by: Just D. | last post by:
Do we have any access to the Session object from a different Session? The idea is to save Session of a current user and then if he logs in again then return the Session back. It's not a problem to...
7
by: Mr Newbie | last post by:
I have written a Custom Control Menu. Its fairly simple but it works well enough. In order to simplify things I decided to store the Menu1 custom control in Session. In the page load event below,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.