Jump to content
Larry Ullman's Book Forums

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

 

 

 

Link to comment
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.

Link to comment
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();
Link to comment
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 

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

 Share

×
×
  • Create New...