Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Sesja gubi zmienne
camikazee
post 17.10.2006, 21:55:22
Post #1





Grupa: Zarejestrowani
Postów: 171
Pomógł: 18
Dołączył: 17.04.2006
Skąd: Bydgoszcz

Ostrzeżenie: (0%)
-----


Witam! Mam problem czesto pojawiajacy sie, aczkolwiek, nie moge sobie poradzic. Pisalem kod z uzyciem sesji
  1. <?
  2.  
  3.  $DefaultCat = 'images';
  4.  define('SESSION_NAME', $_SESSION['name']);
  5.  define('SESSION_USER', $_SESSION['user']);
  6.  define('SESSION_CAT', $_SESSION['cat']);
  7.  define('SESSION_FILE', $_SESSION['file']);
  8.  
  9.  // LOADING CLASS5
  10.  require_once('class/class.directory.php');
  11.  require_once('class/smarty/Smarty.class.php');
  12.  echo SESSION_CAT."1<br>";
  13.  
  14.  if ( SESSION_CAT == '' ) {
  15.  $NameCat = $DefaultCat;
  16.  $_SESSION['cat'] = $NameCat;
  17.  }
  18.  else {
  19.  $NameCat = SESSION_CAT;
  20.  }
  21.  if ( SESSION_USER == '' ) {
  22.  $UserName = 'Gość';
  23.  }
  24.  else {
  25.  $UserName = SESSION_USER;
  26.  }
  27.  echo $UserName."2<br>";
  28.  echo $NameCat."3<br>";
  29.  
  30.  // START FTPSTRUCT CLASS
  31.  $directory = new FtpStruct ($NameCat);
  32.  $directory->ReadDirectory();
  33.  $directory->SortFiles();
  34.  $files = $directory->ShowFiles();
  35.  $path = $directory->GetPath();
  36.  $icon_file = array('zip' => 'icon_zip.gif',
  37. 'exe' => 'icon_exe.gif',
  38. 'txt' => 'icon_txt.gif',
  39. 'dir' => 'icon_dir.gif',
  40. 'pdf' => 'icon_pdf.gif',
  41. '' => 'icon_def.gif');
  42.  
  43.  
  44.  
  45.  // LOADING TEMPLATE  
  46.  $smarty = new Smarty();
  47.  // katalog szablonów
  48.  $smarty->template_dir = 'templates/';
  49.  // katalog na skompilowane szablony
  50.  $smarty->compile_dir = 'templates_c/';
  51.  // katalog na cache
  52.  $smarty->cache_dir = 'cache/';
  53.  $smarty->display('header.tpl'); 
  54.  $smarty->assign('list', $files);
  55.  $smarty->assign('path', $path);
  56.  $smarty->assign('icon', $icon_file);
  57.  $smarty->assign('UserName', $UserName);
  58.  $smarty->assign('FileLimit', SESSION_FILE);
  59.  $smarty->assign('NameCat', $NameCat);
  60.  $smarty->display('index.tpl'); 
  61.  $smarty->display('footer.tpl');
  62.  echo $_SESSION['cat'];
  63.  $_SESSION['name'] = 'kamil';
  64.  $_SESSION['user'] = 'camikazee';
  65. ?>

mozna zauwazyc, ze juz powtykalem w niektorych miejscach sprawdzenie czy i gdzie gubia sie zmienne w sesji, ale w tym miejscu wszystkie sa

dopiero gdy uruchomie strone np.
  1. <?
  2.  echo $_SESSION['name'];
  3.  echo $_SESSION['user'];
  4.  echo $_SESSION['cat'];
  5. ?>

otrzymuje w wyniku puste pola, gdzie ja robie blad?


--------------------
www.fachoweuslugi.pl | www.zlec-usluge.pl | www.pokazsie.pl
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 04:10