0

Hello everybody,

I have a login page which uses sessions to go to different pages and still allow the user to login when he returs to the initial logi.php page, but now I have implemented the different languages and I realize that whenever I hange the language (which is also implemented with sessions), I loose the information of my previous session.

Can anybody help me?

Thanks in advance

Regards

2
Contributors
12
Replies
16
Views
4 Years
Discussion Span
Last Post by escalanterj
0

This is the login.php that what was working before I implemented the sessios for the language:

login.php
<?php
//let's start the session

session_start();

//let's store our posted values in the session variables for later use

$_SESSION['mac'] = $_POST['mac'];
$_SESSION['ip'] = $_POST['ip'];
$_SESSION['username'] = $_POST['username'];
$_SESSION['link-login'] = $_POST['link-login'];
$_SESSION['link-orig'] = $_POST['link-orig'];
$_SESSION['error'] = $_POST['error'];
$_SESSION['chap-id'] = $_POST['chap-id'];
$_SESSION['chap-challenge'] = $_POST['chap-challenge'];
$_SESSION['link-login-only'] = $_POST['link-login-only'];
$_SESSION['link-orig-esc'] = $_POST['link-orig-esc'];
$_SESSION['mac-esc'] = $_POST['mac-esc'];
?>

<?php
   $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];
?>

<?php

?>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>


<link rel="stylesheet" type="text/css" href="/css/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />

Afterwards I modified and got this and the common.php (shown below) plus one php for every language.

login.php

<?php
//let's start the session

session_start();

//let's store our posted values in the session variables for later use

$_SESSION['mac'] = $_POST['mac'];
$_SESSION['ip'] = $_POST['ip'];
$_SESSION['username'] = $_POST['username'];
$_SESSION['link-login'] = $_POST['link-login'];
$_SESSION['link-orig'] = $_POST['link-orig'];
$_SESSION['error'] = $_POST['error'];
$_SESSION['chap-id'] = $_POST['chap-id'];
$_SESSION['chap-challenge'] = $_POST['chap-challenge'];
$_SESSION['link-login-only'] = $_POST['link-login-only'];
$_SESSION['link-orig-esc'] = $_POST['link-orig-esc'];
$_SESSION['mac-esc'] = $_POST['mac-esc'];
?>

<?php
   $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];
?>

<?php
include_once 'include/common.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<!-- HeadSectionDl BEGIN -->
<div id="languages">
<a href="index.php?lang=en"><img src="/signup-paypal/images/en.jpg" width="40" height="30" align="right"/></a>
<a href="index.php?lang=ca"><img src="/signup-paypal/images/ca.jpg" width="40" height="30" align="right"/></a>
<a href="index.php?lang=sp"><img src="/signup-paypal/images/sp.jpg" width="40" height="30"align="right"/></a>
</div>


common.php

<?php

session_start();

header('Cache-control:private'); // IE 6 FIX

if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];

// register the session and set the cookie
$_SESSION['lang'] = $lang;

setcookie('lang', $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en';
}

switch ($lang) {
  case 'en':
  $lang_file = 'en.php';

  break;

  case 'ca':
  $lang_file = 'ca.php';



      break;

      case 'sp':
      $lang_file = 'sp.php';
      break;



  default:
  $lang_file = 'en.php';

}


include_once 'languages/'.$lang_file;

?>

Regards

0

var_dump is useful for seeing data held in an array, similar to print_r.

So for example to get the data within the $_SESSION array you would use:

var_dump($_SESSION);

Any data held in this would then be displayed. Which allows you to see what, if anything, is within this array

var_dump()

print_r

0

I have psession which shows me waht I have if there si something and I can see that there is nothing.

0

please post the content of var_dump($_SESSION); from one of your lang pages. This dont just disappear unless something has destroyed them

Also the content of $_COOKIE

Edited by Squidge

0

The first time it shows this;
array(12) { ["mac"]=> string(17) "00:21:6B:09:80:50" ["ip"]=> string(12) "192.168.3.52" ["username"]=> string(0) "" ["link-login"]=> string(60) "http://192.168.3.1/login?dst=http%3A%2F%2Fwww.easyjet.com%2F" ["link-orig"]=> string(23) "http://www.easyjet.com/" ["error"]=> string(0) "" ["chap-id"]=> string(4) "\272" ["chap-challenge"]=> string(64) "\377\310\212\105\100\365\320\175\151\234\105\277\011\375\370\006" ["link-login-only"]=> string(24) "http://192.168.3.1/login" ["link-orig-esc"]=> string(31) "http%3A%2F%2Fwww.easyjet.com%2F" ["mac-esc"]=> string(27) "00%3A21%3A6B%3A09%3A80%3A50" ["lang"]=> string(2) "sp" } Old Session: lf6rj2f7u86qob4nh3tbs05p50

When I change the language time it shows nothing cause the session is lost, right?.

0

the firs session is ok, and actually I can copy in a file, can I somehow take this information and restore in the actual session?

0

$_COOKIE= array(2) { ["lang"]=> string(2) "sp" ["PHPSESSID"]=> string(26) "lf6rj2f7u86qob4nh3tbs05p50" }

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.