Jump to content

Hello everyone. I have a probem to start a session after I upgraded the domain to 7.3. The content down is my function.php.


xhulio

Recommended Posts

<?php
include_once 'psl-config.php';
 
function sec_session_start() {
    $session_name = 'sec_session_id';   // Set a custom session name 
    $secure = SECURE;
    // This stops JavaScript being able to access the session id.
    $httponly = true;
    // Forces sessions to only use cookies.
    if (ini_set('session.use_only_cookies', 1) === FALSE) {
        header("Location: ../error.php?err=Could not initiate a safe session (ini_set)");
        exit();
    }
    // Gets current cookies params.
    $cookieParams = session_get_cookie_params();
    session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
    // Sets the session name to the one set above.
    session_name($session_name);
    session_start();            // Start the PHP session 
    session_regenerate_id();    // regenerated the session, delete the old one. 
}

Link to comment
Share on other sites

include_once 'psl-config.php';
function sec_session_start() 
{
	$session_name = 'sec_session_id';   // Set a custom session name 
	$secure = SECURE;
	// This stops JavaScript being able to access the session id.
	$httponly = true;
	// Forces sessions to only use cookies.
	if (ini_set('session.use_only_cookies', 1) === FALSE) 
	{
		header("Location: ../error.php?err=Could not initiate a safe session (ini_set)");
		exit();
	}
	// Gets current cookies params.
	$cookieParams = session_get_cookie_params();
	session_set_cookie_params($cookieParams["lifetime"], 
				$cookieParams["path"], 
				$cookieParams["domain"], 
				$secure, 
				$httponly);
	// Sets the session name to the one set above.
	session_name($session_name);
	session_start();            // Start the PHP session 
	session_regenerate_id();    // regenerated the session, delete the old one. 
}

Ok - you seem to be retrieving the pre-set cookie param from the ini file settings and re-setting them to the same values.  Do I not understand what the manual is telling me?  After that you set your own custom name for your session and then starting it up.  I don't understand what your topic title is saying so what is the problem here?

Edited by ginerjm
Link to comment
Share on other sites

Hello thank you very much for your response and for your time. Look the situation is like this because I don't have so much experience in PHP. It is one online quiz in one subdomain that work fine with PHP version 7.1 but when I change to PHP 7.3 the quiz.php file doesn't work it shows an error like this Could not initiate a safe session (ini_set) in Firefox ( in chrome show blank page). The other pages works fine even I log in or I can register for that quiz, but when I try to take the quiz and click there to open the page shows me an error , that I think is because of some changes in PHP 7.3 related with this part of functions.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.