Page 1 of 1

PHP SESSION [not yet solved]

Posted: Sun Apr 17, 2011 1:59 pm
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.

Re: PHP SESSION [need urgent help]

Posted: Sun Apr 17, 2011 2:40 pm
by fugix
Take the session_regenerate_Id out and see what happens. I don't think it Is necessary.

Re: PHP SESSION [need urgent help]

Posted: Sun Apr 17, 2011 3:01 pm
by shuhail
oh! thanks.
I use the rand() for another operation,
now its working.
Thanks.

Re: PHP SESSION [need urgent help]

Posted: Sun Apr 17, 2011 3:20 pm
by fugix
No problem

Re: PHP SESSION [need urgent help]

Posted: Mon Apr 18, 2011 7:14 am
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

Re: PHP SESSION [need urgent help]

Posted: Mon Apr 18, 2011 7:18 am
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();
		}

Re: PHP SESSION [not yet solved]

Posted: Mon Apr 18, 2011 10:15 am
by shuhail
someone please help me solve this....
I am getting bored now.

Re: PHP SESSION [not yet solved]

Posted: Mon Apr 18, 2011 10:52 am
by fugix

Re: PHP SESSION [not yet solved]

Posted: Mon Apr 18, 2011 4:44 pm
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