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 8881433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:20:48+00:00 2026-06-14T20:20:48+00:00

I have the following code: <?php ini_set(‘display_errors’, ‘On’);error_reporting(E_ALL | E_STRICT); session_start(); set_include_path(‘../include’); if(isset($_GET[lang]) &&

  • 0

I have the following code:

<?php
ini_set('display_errors', 'On');error_reporting(E_ALL | E_STRICT);
session_start();
set_include_path('../include');
if(isset($_GET["lang"])
    && $_GET["lang"] != $_SESSION["lang"]
    && ($_GET["lang"] == 'en' || $_GET["lang"] =='pt')){
$_SESSION["lang"]= $_GET["lang"];
setcookie("lang", $_GET["lang"]);
}
if(!isset($_SESSION["lang"])){
    if(isset($_COOKIE["lang"])){
    echo $_SESSION["lang"] == $_COOKIE["lang"];
    } else {
        switch(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)){
        case 'pt': $_SESSION["lang"] = "pt";setcookie("lang", $_SESSION["lang"]); break;
        default: $_SESSION["lang"] = "en";setcookie("lang", $_SESSION["lang"]);
        }

    }
}
print_r($_SESSION);print_r($_GET);print_r($_COOKIE);
require('lang/'.$_SESSION["lang"].'.php');
?>

But for some reason the $_SESSION variables do not retain values. The output is the following:

Notice: Undefined index: lang in /home/claudio/public_html/index.php
on line 13 Array ( ) Array ( [get] => get ) Array ( [lang] => en
[PHPSESSID] => c92d58e58508gvjf2urfmr9uh3 ) Notice: Undefined index:
lang in /home/claudio/public_html/index.php on line 23

Warning: require(lang/.php): failed to open stream: No such file or
directory in /home/claudio/public_html/index.php on line 23

Fatal error: require(): Failed opening required ‘lang/.php’
(include_path=’../include’) in /home/claudio/public_html/index.php on
line 23

If i do echo session_start(); it returns 1, so what can be the problem with the session?

  • 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-14T20:20:49+00:00Added an answer on June 14, 2026 at 8:20 pm

    if $_GET["lang"] and $_SESSION["lang"] are not set and $_COOKIE["lang"] is set, the only thing executed would be:

    echo $_SESSION["lang"] == $_COOKIE["lang"]; //maybe this should be a '='?
    

    If this is not the case, maybe you should check if the session save path in /var/php_sessions is writable by the web server.

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

Sidebar

Related Questions

I have the following code: error_reporting(E_ALL); ini_set(display_errors, 1); $db = mysqli_connect(db.mysql,user,pwd,db); $consumersecret = Cy4qwsC1fdvP62x------BiEQMLwbDUUA;
In an action method, I have the following excerpt of code: error_reporting(E_ALL); ini_set('display_errors', '1');
<?php ini_set('display_errors',1); error_reporting(E_ALL); session_start(); $targ_w = $targ_h = 150; $jpeg_quality = 90; $ext=$_GET['ext']; $src
i have the following PHP code: <?php ini_set( 'default_charset', 'UTF-8' ); mb_internal_encoding('UTF-8'); function labelValidate($label)
In my Zend Framework app, I have following code: index.php $app_started_time = time(); layout.phtml
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
I have the following PHP code, and for the life of me I can't
I have the following php code: $k=1; for($i=0; $i < 5; $i++) { $stmt
I have the following php code: $k=1; for($i=0; $i < 5; $i++) { $stmt

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.