Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:05:38+00:00 2026-06-04T21:05:38+00:00

I’ve read all the posts I could find about this issue, but, to date,

  • 0

I’ve read all the posts I could find about this issue, but, to date, none of the solutions have worked for me. Obviously, I’m overlooking something important. I also don’t know how to debug sessions. I read one article, PHP session Debugging, but it was over my head.

So, much like the other issues, when I navigate to another page in my app, whether through a link or a form submit, my session disappears. I have no idea why my session vanishes. If someone has the time to help me investigate, it would be greatly appreciated.

These are my php.ini settings

; Name of the session (used as cookie name).  
session.name = PHPSESSID  

; The path for which the cookie is valid.  
session.cookie_path = /

This is the first view to display

<?php
session_start();
if (!isset($_SESSION['session_id'])) {
    $_SESSION['session_id'] = session_id();
}
if (!isset($_SESSION['invoices'])) {
    $_SESSION['invoices'] = $invoices;
}

if (isset($_SESSION['session_id'])) {
    print_r($_SESSION['session_id'] . " in invoiceList.<br />");
} else {
    echo 'No session ID set in invoiceList <br />';
}
?>
<div>

    <table>
        <tr>            
            <th>Customer Name</th>
            <th>Invoice Date</th>
            <th>Invoice Number</th>
        </tr>
        <tr>
            <?php
            include_once 'form/editInvoice.php';
            if (isset($invoices)) {

                foreach ($invoices as $invoice) {
                    ?>
                <tr>
                    <td><?php echo $invoice['customer_name'] ?></td>
                    <td><?php echo $invoice['invoice_date'] ?></td>
                    <td><?php echo $invoice['invoice_number'] ?></td>
                    <td><a href='<?php echo $_SERVER['SCRIPT_NAME']; ?>/retrieve?class=InvoiceLineItems&amp;id=<?php echo $invoice['invoice_id']; ?>'><?php echo $invoice['invoice_id']; ?></a></td>
                </tr>
                <?php
            }
        } else {
            echo 'No invoices retrieved.';
        }
        ?>
        </tr>
    </table>
</div>  

Here is the included form:

<?php
session_start();

if (isset($_SESSION['session_id'])) {
    print_r($_SESSION['session_id'] . "in editForm<br />");
} else {
    echo 'No session ID set in editForm <br />';
}

if (!$_POST) {
    ?>

<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
        <fieldset>
            <legend>Enter Updated PO Number</legend>
            <li>PO Number: <input type="text" name="po_number"/></li>
        </fieldset>
        <input type="submit" value="Submit" />
        <input type="button" onclick="alert('Changes Canceled.')" value="Cancel"/>
    </form>
<?php }
?>

And finally, the detail page for when the user clicks a link in the main page.

<?php
session_start();

if (isset($_SESSION['session_id'])) {
    print_r($_SESSION['session_id'] . "<br />");
} else {
    echo 'No session ID set invoice<br />';
}
?>

<h1>Invoice Detail</h1>
<div>
<?php
foreach ($partnerInfo as $info) {

    switch ($info['role_indicator']) {
        case 'remit_to':
            ?>
            <div id="remit">
                <ul>
                    <li>PLEASE REMIT TO:</li>
                    <li><?php echo $info['partner_name']; ?></li>
                    <li><?php echo $info['street_name']; ?></li>
                    <li><?php echo $info['city_name']; ?>, <?php echo $info['state']; ?> <?php echo $info['postal_code']; ?></li>

                </ul>
            </div>
            <?php break; ?>
        <?php case 'seller': ?>
            <div id = "seller" >
                <ul>
                    <li>Service Site:</li>
                    <li><?php echo $info['partner_name']; ?></li>
                    <?php
                    if ($info['partner_aux_info'] !== NULL) {
                        ?><li><?php echo $info['partner_aux_info']; ?>
                        <?php }
                        ?>
                    </li>
                    <li><?php echo $info['street_name']; ?></li>
                    <li><?php echo $info['city_name']; ?>, <?php echo $info['state']; ?> <?php echo $info['postal_code']; ?></li>
                    <li>(405)677-0221</li>
                </ul>        
            </div>
            <?php break; ?>
        <?php case 'sold_to': ?>
            <div id="buyer">
                <ul>
                    <li>Bill To: </li>
                    <li><?php echo $info['partner_name']; ?></li>
                    <li><?php echo $info['street_name']; ?></li>
                    <?php
                    if ($info['suite_info'] !== NULL) {
                        ?><li><?php echo $info['suite_info']; ?>
                        <?php }
                        ?>
                    </li>
                    <li><?php echo $info['city_name']; ?>, <?php echo $info['state']; ?> <?php echo $info['postal_code']; ?></li>
                </ul> 
            </div>   
            <?php break; ?>
        <?php
    }
}
?>
<h1>Line Items</h1>
<table>
    <th>PO Number</th>
    <th>PO Issued Date</th>
    <th>Description</th>
    <th>Service Start Date</th>
    <th>Service End Date</th>
    <th>Shipped Date</th>

    <?php foreach ($invoiceLineItems as $lineItem) { ?>
        <tr>
            <td><?php echo $lineItem['po_number']; ?></td>
            <td><?php echo $lineItem['po_issued_date']; ?></td>
            <td><?php echo $lineItem['line_item_name']; ?></td>
            <td><?php echo $lineItem['service_period_start']; ?></td>
            <td><?php echo $lineItem['service_period_end']; ?></td>
            <td><?php echo $lineItem['request_for_delivery']; ?></td>
        </tr>       
        <?php
    }
    ?>

</table>


</div>

Edit: I’ve removed the session checks and updated the code sample. I’ve added session_start() before my <head> tag in index.php. I’ve verified that I can write to the session temp folder.

When i execute this code in my controller to update the invoices with the new PO number, I reach the model’s function, but the session is gone.

//If form is posted, update line items with PO number and date.
if (isset($_POST['po_number'])) {
    $this->invoice->update();
}

By the time I reach the session variable assignment, I have no session data:

public function update() {

$con = $this->_getLocalConn();


$invoices = $_SESSION['invoices'];

try {
    $sqlUpdate = $con->prepare("UPDATE invoices 
                                SET po_number = ?, po_issued_date = ?
                                WHERE invoice_id = ?");

    foreach ($invoices as $record) {
        $sqlUpdate->execute(array(
            $_POST['po_number'],
            getdate(),
            $record['invoice_id']
        ));
    }
} catch (PDOException $e) {
    print $e->getMessage();
}
//get the PO number being used to update the records
//perform db update where po_number = input
//notify user of success and display updated records.

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:05:39+00:00Added an answer on June 4, 2026 at 9:05 pm

    Each PHP file should start with session_start(); regardless of $_SESSION being set or not. This function will create a new session OR take up the existing one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.