help for session management

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
sangram_tek
Forum Newbie
Posts: 1
Joined: Tue Oct 31, 2006 4:52 am

help for session management

Post by sangram_tek »

i am establishing a session after varifying users userid and password accesssing from database.

Code: Select all

<?php
session_start();
$uid = $_POST['uid'];
$pass = $_POST['pwd'];
 $_SESSION['uidsession']="$uid";
	$_SESSION['passwordsession']="$pass";
	$URL="./myaccount.php";
     header ("Location: $URL");
	echo '<br /><a href="logout.php?'.SID.'">Log Out</a>';
    }
My Problem is that while user is getting logout ,and once again getting loged in without closing that broweser.
i am finding this error.

Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/teknowed/greatindian.in/marble/myaccount/login.php:16) in /hsphere/local/home/teknowed/greatindian.in/marble/myaccount/login.php on line 345
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

You can only set Headers if nothing has been output to the browser. In login.php ensure no whitespace exists before the opening PHP tag, or after the closing ?> tag.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Moved to PHP - Code
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post by sh33p1985 »

unless you can show us line 16 (or preferably 14-18) cant help you identify where your script is outputting whitespace when it shouldnt be. it could be some variable you have output to test your script and have forgotten to remove. go through your script slowly and make sure there are no occurrences such as this!:P
wyrmmage
Forum Commoner
Posts: 56
Joined: Sat Oct 28, 2006 12:43 pm
Location: boise, ID

Post by wyrmmage »

Post Reply