Hi!

I'm getting these warnings:
Warning: session_start() [function.session-start]: Node no longer exists in (file) on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at file:2) in file on line 2

Warning: Unknown: Node no longer exists in Unknown on line 0

I have a xml file. Php takes some information from this file, and it saves it in $_SESSION. But something's wrong. What?

function convert($text){
//some code
}
$username=$_POST['user_name'];
$password=$_POST['password'];
$password=md5($password);
$cood=$_POST['cood'];
include("sigurnost/securimage.php");
$img=new Securimage();
$valid=$img->check($cood);
if($valid==true){
$xml=new SimpleXMLElement('database/data.xml',null,true);
foreach($xml as $data){
if($data->userName==$username && $data->password==$password){
session_start();
$_SESSION['name']=convert($data->name);
$_SESSION['cognomen']=convert($data->forname);
$_SESSION['username']=convert($data->userName);
$_SESSION['id']=$data->id;
$_SESSION['password']=$data->password;
$_SESSION['email']=convert($data->email);
session_register("user_Name");
header("location:ok.php");
}
}
}else $error="1";
Member Avatar for cuonic

Apparently line 2 is at fault, but sadly you have removed it and replaced with a comment...

Please give us the FULL php code

OK. Here's full code:

$korime=$_POST['korisnicko_ime']; //user name
$lozinka=$_POST['lozinka']; //password
$lozinka=md5($lozinka);
$kod=$_POST['kod']; //code - code in picture
include("sigurnost/securimage.php");
$img=new Securimage();
$valid=$img->check($kod);
if($valid==true){
include("converter.php"); //in this file is function convert()
$xml=new SimpleXMLElement('database/data.xml',null,true);
foreach($xml as $data){
if($data->nomenUsoris==$korime && $data->tessera==$lozinka){
session_start();
$_SESSION['nomen']=convert($data->nomen); //name
$_SESSION['cognomen']=convert($data->cognomen); //surname
$_SESSION['nomenUsoris']=convert($data->nomenUsoris); //user name
$_SESSION['id']=$data->id;
$_SESSION['tessera']=$data->tessera; //password
$_SESSION['email']=convert($data->email);
session_register("korisnicko_ime");
header("location:prijavljen.php");
}
}
}else $error="1";

Here's converter.php:

<?php
function convert($tekst){
$zamijena=array('/#c=/','/#C=/','/#c-/','/#C-/','/#s=/','/#S=/','/#z=/','/#Z=/','/#d-/','/#D-/');
$zamijeniti=array('č','Č','ć','Ć','š','Š','ž','Ž','đ','Đ');
return preg_replace($zamijena,$zamijeniti,$tekst);
}
?>

In xml file, I use #c= instead of č etc., because there's some mistake if I use č...
I use xml file for database, because mysql database sometimes on server doesn't work.

session_start(); -->Should be at very top of the file, before anything else. That is the best practice to avoid headers already sent error!
try rectifying this and post any error/warning you get

I found mistake:

<?php
session_start();
echo $_SESSION['nomen']."<br>";
echo $_SESSION['cognomen']."<br>";
echo $_SESSION['nomenUsoris']."<br>";
echo $_SESSION['id']."<br>"; //blank
echo $_SESSION['tessera']."<br>"; //blank
echo $_SESSION['email']."<br>";
?>

So, $_SESSION and $_SESSION are blank. They don't use function convert. Can somebody now help?

This helped me (I found it on some site):

$_SESSION['sessionName']=(string)$data->xml;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.