Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Derekd

Db_Sessions Problem

Recommended Posts

Hello all,

 

All my scripts using database sessions work fine, except for this one..... Probably kick myself when I finally get the light bulb to go on.

 

Here is some of the relevant code and accompanying errors, hope somebody can help me.

 

<?php
require_once('./includes_proc/config.inc.php');
$page_title = 'Select My Other Properties';
include('./includes_proc/header_c5.php');

 if(isset($_POST['submitted'])) {        
    if(isset($_POST['prop'])) {
        $new_prop = (int) $_POST['prop'];

etc....

 

The header script that gets included...

 

 

<?php

/*
 * This page begins the HTML header for the site.
 * The header alse creates the right hand column.
 * This page call session_start()
 *
 */
 // Start session if not logged in
 if(!isset($_SESSION['in'])) {
     ob_start();
      require_once('db_sessions.inc.php');
 }
 
 // Check for a $page_title value:   -  etc..........

 

 

The script starting db_session....

 

# **************************** #
# ***** END OF FUNCTIONS ***** #
# **************************** #

// Declare the functions to use:
session_set_save_handler('open_session', 'close_session', 'read_session', 'write_session', 'destroy_session', 'clean_session');

// Make whatever other changes to the session settings.

// Start the session:
session_start();   -   ( Line 123)

?>

 

An abbreviated version of the error data.....

 

An error occurred in script '/home/luxacom/public_html/

busapp_proc/includes_proc/db_sessions.inc.php' on line 123:
<br />session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/luxacom/public_html/busapp_proc/sel_prop.php:2)
<br />Date/Time: 4-21-2013 15:43:04
<br /><pre>Array
(

[_REQUEST] => Array
        (
            [phpSESSID] => 058975b6b1eb4dc22bc8cf28b31fd0

80
        )

    [contact_email] => luxadry@gmail.com
    [local] =>
    [debug] =>
    [dbc] => mysqli Object
        (
        )

    [page_title] => Select My Other Properties
    [sdbc] => mysqli Object
        (
        )

    [HTTP_SESSION_VARS] => Array
        (
            [op_units] => 1
            [van] => 3
            [agent] => f76e1da45697f2bea834d3cc529b10fb
            [cid] => 526
            [in] => 526
            => mentone@gmail.com
            [id_prop] => 567
            [cust_type] => residential
            [mult_props] => 1
        )

    [_SESSION] => Array
        (
            [op_units] => 1
            [van] => 3
            [agent] => f76e1da45697f2bea834d3cc529b10fb
            [cid] => 526
            [in] => 526
            => mentone@gmail.com
            [id_prop] => 567
            [cust_type] => residential
            [mult_props] => 1
        )

)
</pre>
<br />

 

Hope this makes sense

 

Derek

 

 

 

Share this post


Link to post
Share on other sites

No, I mean that you are getting a "Headers already sent" error, which means that you are outputting something to the browser before the session_start function.

Do a search for the text below on the following page:

http://php.net/manual/en/function.session-start.php

"Headers already sent"

 

You'll see that many people have had the same problem, and have posted their solutions.

Share this post


Link to post
Share on other sites

You need to start the session even if you are using output buffering. You have checked for a session variable before you start the session so I think that's why you are getting the error.

 if(!isset($_SESSION['in'])) {
     ob_start();

Share this post


Link to post
Share on other sites

Thanks for that Margaux, and sorry I am only responding now (hectic times). With the help from this board and some revision, all my issues around db_sessions are now resolved.

 

Thank you to everyone.

 

Cheers

 

Derek 

Share this post


Link to post
Share on other sites

Hi,

 By the way the problem that existed in the "select other properties" script, was that the first line of code was empty. Must have hit enter by my mistake on the first line when doing the code for the script. I knew I would end up kicking myself.

 

Cheers

 

Derek

Share this post


Link to post
Share on other sites

I've had that problem before too, where I *know* what the problem is, but I still can't find it.

Good job though. I bet that that was one heck of a eureka moment when you finally solved the problem.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...