PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 17, 2019 5:05 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Apr 11, 2013 9:21 pm 
Offline
Forum Newbie

Joined: Thu Apr 11, 2013 9:01 pm
Posts: 2
I'm new to PHP. Have gotten a simple login system working. Each page has
Syntax: [ Download ] [ Hide ]
<?php include "base.php";?>

at the top. base.php contains:
Syntax: [ Download ] [ Hide ]
<?php
session_start();
?>
 

I do call several other php files during the course of things. It works fine, but I found here:

that in order to prevent session hijacking, I should add a line to make my base.php file look like this:
Syntax: [ Download ] [ Hide ]
<?php
session_start();
session_regenerate_id(true);
?>
 


Everything works fine except now I get a warning every time I execute any of my pages (all of them including this code at the top). The warning is this:
Syntax: [ Download ] [ Hide ]
[11-Apr-2013 22:19:34 America/New_York] PHP Warning:  session_regenerate_id(): Cannot regenerate session id - headers already sent in /home/tomsgood/public_html/base.php on line 3
 

The searching I did on the web doesn't seem to help me find out why this warning is happening or how to stop it.


Top
 Profile  
 
PostPosted: Fri Apr 12, 2013 1:06 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
PostPosted: Fri Apr 12, 2013 7:33 am 
Offline
Forum Newbie

Joined: Thu Apr 11, 2013 9:01 pm
Posts: 2
Yes, the "include base.php" line has to come before everything. (At least that's what I learned a couple years ago when I first got it working in it's present state.)


Top
 Profile  
 
PostPosted: Fri Apr 12, 2013 2:29 pm 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group