PHP SESSION [not yet solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

PHP SESSION [not yet solved]

Post by shuhail »

I am trying to assign user a random session id.
index.php

Code: Select all

@session_start();
if(!isset($_SESSION['SESS_MEMBER_ID']))
	{session_regenerate_id();
	$_SESSION['SESS_MEMBER_ID'] = 'rand(000000,444444)';
	session_write_close();}
when user logged in to their account, session id will replaced by their email address.
login.php

Code: Select all

			//Login Successful
			session_regenerate_id();
			$member = mysql_fetch_assoc($result);
			$_SESSION['SESS_MEMBER_ID'] = $login;
			session_write_close();
			header("location: ../member.php");
			exit();
but in index page,
Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in index.php on line 2

and in the login page,


Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in login.php
Warning: Cannot modify header information - headers already sent by (output started at login.php:1) in login.php


I need to fix this now.
please help me.
Last edited by shuhail on Mon Apr 18, 2011 7:20 am, edited 1 time in total.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: PHP SESSION [need urgent help]

Post by fugix »

Take the session_regenerate_Id out and see what happens. I don't think it Is necessary.
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Re: PHP SESSION [need urgent help]

Post by shuhail »

oh! thanks.
I use the rand() for another operation,
now its working.
Thanks.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: PHP SESSION [need urgent help]

Post by fugix »

No problem
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Re: PHP SESSION [need urgent help]

Post by shuhail »

I am facing a new problem.
I've uploaded the file to 2 different server.
please check:

http://www.cine29.com/fairly [its working perfectly.]
but in original site, its showing the same error,

Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in login.php
Warning: Cannot modify header information - headers already sent by (output started at login.php:1) in login.php


please check:
http://www.fairly-legal-incense.com
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Re: PHP SESSION [need urgent help]

Post by shuhail »

Code: Select all

if(mysql_num_rows($result) == 1) {
			//Login Successful
			session_regenerate_id();
			$member = mysql_fetch_assoc($result);
			$_SESSION['SESS_MEMBER_ID'] = $login;
			$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
			$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
			session_write_close();
			header("location: ../shipd.php");
			exit();
		}
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Re: PHP SESSION [not yet solved]

Post by shuhail »

someone please help me solve this....
I am getting bored now.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: PHP SESSION [not yet solved]

Post by fugix »

User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: PHP SESSION [not yet solved]

Post by Darhazer »

The problem is that you have output in your logging.php
Make sure it begins with <?php tag and has no HTML output before the code you are showing us
Post Reply