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.

Sessions Again

In Win32, php4: (I don't have access to the php.ini file.)

With 'session_start()', how do I avoid the complaint "PHP Notice: A session
had already been started" ?
Without 'session_start()', I get the "Undefined variable: _SESSION "
complaint.

Any hope? (I'll be happy simply to suppress the error message, although I AM
trying to understand what's behind it.).

Thanks, all.

AS

Dec 10 '05 #1
3 3552
Arnold Shore wrote:
With 'session_start()', how do I avoid the complaint "PHP Notice: A
session had already been started" ?
Normally this happens when the session.auto_start directive has been enabled
in the php.ini file while calling session_start().
Without 'session_start()', I get the "Undefined variable: _SESSION "
complaint.

This should not happen when you do a simple "print_r($_SESSION)" on top of
your script and sounds like a configuration problem. Ask your administrator
about this.
Any hope? (I'll be happy simply to suppress the error message,
although I AM trying to understand what's behind it.).


Prepending an at-sign will surpress the notice:

@session_start();
JW
Dec 10 '05 #2
*** Arnold Shore escribió/wrote (Sat, 10 Dec 2005 16:36:10 -0500):
With 'session_start()', how do I avoid the complaint "PHP Notice: A session
had already been started" ?
Without 'session_start()', I get the "Undefined variable: _SESSION "
complaint.

Any hope? (I'll be happy simply to suppress the error message, although I AM
trying to understand what's behind it.).


Try this on top of your code:

ini_set('session.auto_start', '0');

I haven't tested but may do the trick. In any case, it'd be interesting to
see the actual code that claims about $_SESSION being undefined, because
when you start a session twice the exact notice is:

A session had already been started - ignoring session_start()

"Ignoring" sounds like, well, no point in using that code :-?

--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Dec 10 '05 #3
Arnold Shore wrote:
With 'session_start()', how do I avoid the complaint "PHP Notice: A session
had already been started" ?
Without 'session_start()', I get the "Undefined variable: _SESSION "
complaint.

<snip>

Maybe you're trying to do session_start() more than once.

Try this:
<?php
echo 'ini_get('session.auto_start') is ',
ini_get('session.auto_start'), "<br>\n";
echo 'before session_start() session_id() returns ', session_id(),
"<br>\n";

// You may want to replace your session_start()s with this too
if (!session_id()) session_start();

echo 'after session_start() session_id() returns ', session_id(),
"<br>\n";
?>

Dec 11 '05 #4

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
10
by: Marcus | last post by:
Hi All, First, just wanted to say that I found what I thought was a very helpful tutorial on sessions in case anyone out there has questions on them: ...
22
by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of everything and a cookie is used to accept or deny...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
10
by: Mark H | last post by:
Hey all-- I'm building a database and I basically need to keep out people who aren't authorized, but it's not like I need top security here. I'm just doing basic user/pass of a SQL database, and...
3
by: Will Woodhull | last post by:
Hi, I'm new here-- I've been reading the group for a couple of days. Nice group; I like the way n00b33 questions are handled. I've been using a Javascript routine in index.html to determine a...
1
by: D A H | last post by:
I have gotten the same exception in multiple projects. I have solved the underlying problem. My question is if anyone knew of a setting that would cause this exception to be thrown. A...
12
by: D. Shane Fowlkes | last post by:
This is a repost (pasted below). Since my original post, I've double checked the system clock and set all IIS Session Timeout values to 10 minutes. Still ...the problem occurs. I've also...
10
by: newbie | last post by:
My application_end event in global.asax is not working as-is. In order to debug, I want to call it from another file, say debug.aspx through a button, e.g. "end application". How do I call...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.