473,387 Members | 1,779 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,387 software developers and data experts.

Quick question on session_start()


Folks,

I consider myself a reasonably strong PHP programmer, but I've not used
sessions before (I've used cookies instead) and I'd appreciate it if
someone could confirm something for me.

Namely... I'm working on someone else's code who has used sessions - In
their main login page, they do not use session_start() but instead, just
write directly to the $_SESSION super global array variable. This seems
to work - however on some later pages, he has session_start() noted at
the top of his code - I've read some of the documentation on sessions
and I believe that since I am using Apache 1.3.29 with PHP 4.3.6 that it
may not be nescessary to have the session_start().

A quote from the php.net documentation says:

"Note: As of PHP 4.3.3, calling session_start() while the session has
already been started will result in an error of level E_NOTICE. Also,
the second session start will simply be ignored."

Thus, can one start a session by simply writing to the $_SESSION super
global array and forget about every using session_start() ????

Help via the newsgroup (so everyone can learn) would be much
appreciated, thanks

randelld
Jul 17 '05 #1
2 1914
Reply-Via-Newsgroup Thanks wrote:

Folks,

I consider myself a reasonably strong PHP programmer, but I've not used
sessions before (I've used cookies instead) and I'd appreciate it if
someone could confirm something for me.

Namely... I'm working on someone else's code who has used sessions - In
their main login page, they do not use session_start() but instead, just
write directly to the $_SESSION super global array variable. This seems
to work - however on some later pages, he has session_start() noted at
the top of his code - I've read some of the documentation on sessions
and I believe that since I am using Apache 1.3.29 with PHP 4.3.6 that it
may not be nescessary to have the session_start().

A quote from the php.net documentation says:

"Note: As of PHP 4.3.3, calling session_start() while the session has
already been started will result in an error of level E_NOTICE. Also,
the second session start will simply be ignored."

Thus, can one start a session by simply writing to the $_SESSION super
global array and forget about every using session_start() ????

Help via the newsgroup (so everyone can learn) would be much
appreciated, thanks


IIRC referring to $_SESSION performs an implicit session_start(). I
usually put it in there anyway.
Jul 17 '05 #2
Kevin Thorpe wrote:
Reply-Via-Newsgroup Thanks wrote:
Namely... I'm working on someone else's code who has used sessions - In
their main login page, they do not use session_start() but instead, just
write directly to the $_SESSION super global array variable. This seems
to work - however on some later pages, he has session_start() noted at
the top of his code - I've read some of the documentation on sessions
and I believe that since I am using Apache 1.3.29 with PHP 4.3.6 that it
may not be nescessary to have the session_start().
IIRC referring to $_SESSION performs an implicit session_start(). I
usually put it in there anyway.


It depends on session.auto_start in php.ini

You can check it if your script might be running in several different
servers with different configurations:

<?php
if (ini_get('session.auto_start') != '1') session_start();
?>
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3

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

Similar topics

3
by: Florence HENRY | last post by:
Hello, I've searched about my problem on google before posting, but I didn't find anything relevant... I have a problem with session_start. Here is my code : <html> <head> <?php...
19
by: Chris Allen | last post by:
Hi I'm new to PHP and I'm trying to create a Login Form. Once the user has logged in then he shouldn't have to log in again. The trouble is I'm getting a new session ID between every page and so...
4
by: Bob | last post by:
Seem to have a problem ending a session. I get the following message. Warning: session_start(): Cannot send session cookie - headers already sent by (output started at...
5
by: Ben | last post by:
Hi all, In my .php file, I'm using both session_start() and setcookie() before <html> tag. It gives me following warning message: Warning: Cannot modify header information - headers already...
3
by: Trogdor | last post by:
I set up a server on an AMD 650 machine running gentoo linux. I installed Apachie 2, MySQL 4.1 and PHP 4.3.11 I use another computer on my local net (192.168.0.x) to access the server as a...
8
by: lkrubner | last post by:
I was trying to set a cookie before I called session_start() and it was giving me an error. But isn't sessions really just a cookie? Why would it matter if I sent a cookie before session_start? Can...
3
by: Greg Scharlemann | last post by:
Does the redirect statement: header(Location:"http://www.newpage.com"); need to come before certain statements? I've setup a login page and try to redirect a user once they have logged in...
5
by: Niklas Uhlin | last post by:
Someone please explain why Session_Start fires multiple times / retains SessionID values between sessions, when you open an ASP.NET page from MS Word. For details of the problem, see below: 1....
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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.