Save cart into cookies or database, if the user is not logged in

Hi!
I want to keep cookies for the baskets a few days.
I am using the parameters in the file ini.php:
[B]session.cookie_lifetime 864000
session.gc_maxlifetime 172800
session.use_cookies On On
session.use_only_cookies Off
session.use_trans_sid 1[/B]
When I put the product to cart, I have cookies “[B]sid[/B]” and “[B]sid_key[/B]”. Cookie “[B]sid_key[/B]” disappears, if you close your browser. And the basket disappears too, if the user is not logged in.
I look at the file oxbasket.php.
Functions:

    protected function _save()
    {
        if ( $this->_canSaveBasket() ) {

            if ( $oUser = $this->getBasketUser() ) {
                //first delete all contents
                //#2039
                $oSavedBasket = $oUser->getBasket( 'savedbasket' );
                $oSavedBasket->delete();

                //then save
                foreach ( $this->_aBasketContents as $oBasketItem ) {
                    // discount or bundled products will be added automatically if available
                    if ( !$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle() ) {
                       $oSavedBasket->addItemToBasket( $oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(), true, $oBasketItem->getPersParams() );
                    }
                }
            }
        }
    }

    public function deleteBasket()
    {
        $this->_aBasketContents = array();
        $this->getSession()->delBasket();

        if ($this->getConfig()->getConfigParam( 'blPsBasketReservationEnabled' )) {
            $this->getSession()->getBasketReservations()->discardReservations();
        }

        // merging basket history
        if ( !$this->getConfig()->getConfigParam( 'blPerfNoBasketSaving' ) ) {
            $this->_deleteSavedBasket();
        }
    }

I want to keep cart in cookies or a database, if the user is not logged in. How can I do this?
Thank you!

Hi, friends!
I did it.
I have for a lifetime of cookies [B]sid_key[/B]:
File [I]oxsession.php[/I]:

//if we have no cookie then try to set it
if ( !$sCookieSid ) {
            oxUtilsServer::getInstance()->setOxCookie( 'sid_key', 'oxid', time()+15724800 );
}

I also disabled the checkbox “Don’t save Shopping Carts of registered Users” and cleared the field in the database [B]oxuserbasketitems [/B]and [B]oxuserbaskets[/B].
[B]P.S.This is my experiment! This is not a recommendation![/B]

Thanks for letting us know!