Reply LinkBack Thread Tools Search this Thread
Old 15-04-2004, 10:14   #1 (permalink)
deliben
Registered User
 
Join Date: Apr 2004
Posts: 7
session problems desperately seeking solution !

Hi,

I am having a huge Session problem. I know that after a user is loged in thats where the session begins to start. I do update the DB so that I insert the session_id() to the data record where the user id is set. Then I know the session starts because I see in the browser that the PHPSESID is attached to the site I apply. However I donīt see that on every site I apply. I even donīt know if I have to see the PHPSESID is attached. I have to admit I have never worked with sessions.

There is a search routine in my project where the user can select a link whether the user wants to search a customer by company or by first name or by last name. After the selection the user now can typ in the term to search for. The result of that search will be created as a link where the user only can see the first name and the last name of the customer for more details the user then can select the link he want to where the detail.php is called and the details of the customer is shown.

This is where the problem starts. To recognize wich customer is selected I attache the .$row['ID']. to the detail.php . And on the detail.php I form the sql query by .$_REQUEST['rid']. (see code below)

select.php :

<?php
while ($row =mysql_fetch_assoc($result)):
echo("<a href=\"detail.php?rid=".$row['ID']."\">".$row['fname']." ".$row['lname']."</a>");

endwhile;
}

?>

detail.php:


<?php
$sql = "select customers.fname, customers.lname,
customers.number, customers.email, company.name,
city.name from customers,company,city
where customers.companyID=company.ID
AND customers.cityID=city.ID
AND customers.ID='" .$_REQUEST['rid']. "'";

$result = mysql_query($sql);

?>

Somehow I do get the details shown but I also get the following Warnings.

- Warning: session_start(): Cannot send session cookie- headers already sent by (output started at W:\www.detail.php:1) in W:\www.detail.php on line 2

- Warning: session_start(): Cannot send session cache limiter- headers already sent by (output started at W:\www.detail.php:1) in W:\www.detail.php on line 2

- Warning: session_start(): Cannot modify header information- headers already sent by (output started at W:\www.detail.php:1) in W:\www.detail.php on line 2

line 2 is where session_start() is located.

Can some php guru please help me ?
  Reply With Quote
Old 15-04-2004, 14:14   #2 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
I've been out for beers and just reading that gave me a headache.

You have to start your sessions before anything else on the page. Are you doing that?
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 15-04-2004, 14:55   #3 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,193
Quote:
Originally Posted by smallbeer
I've been out for beers and just reading that gave me a headache.

You have to start your sessions before anything else on the page. Are you doing that?

he can't be, else the headers wouldn't have been sent already.

in the file with session_start, ensure it's the first thing listed, and also make sure this file isn't been included in another file (hence the 'headers already sent' malarky).

this is by far the most common problem encountered with sessions - try googling a bit too
__________________
Random goodness at The Blog™

  Reply With Quote
Old 15-04-2004, 15:02   #4 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
Quote:
Originally Posted by i_am_cam
in the file with session_start, ensure it's the first thing listed
that's what I meant to say, in a round-about kind of way.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 16-04-2004, 04:01   #5 (permalink)
deliben
Registered User
 
Join Date: Apr 2004
Posts: 7
Thanks for the reply guys. I just want to say that all my files start with

<?php
session_start();
..
..
....

I donīt think that this is causing the problems I mentioned.

Waht do u think ?
  Reply With Quote
Old 16-04-2004, 05:27   #6 (permalink)
DaiWelsh
Registered User
 
Join Date: Mar 2004
Location: Derby, UK
Posts: 24
Even white space can cause problems, so is the < of <?php literally the first byte of the file?
Also, make sure you do not auto include any code that would generate output.
  Reply With Quote
Old 16-04-2004, 05:39   #7 (permalink)
deliben
Registered User
 
Join Date: Apr 2004
Posts: 7
Quote:
Originally Posted by DaiWelsh
Even white space can cause problems, so is the < of <?php literally the first byte of the file?
Also, make sure you do not auto include any code that would generate output.


Funy but somehow I donīt get those warnings anymore. What I did is Iīve rechecked every singl file I use in my project and removed any possible whitespace that eventually would cause a problem.

But I am still not sure if there is a session restart or a new session start or not, refered to
..
echo("<a href=\"detail.php?rid=".$row['ID']."\">".$row['fname']." ".$row['lname']."</a>");
...

????
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8