Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Mencantumkan kode program di posting Anda, tolong ikuti aturan yang sesuai, baca http://diskusiweb.com/discussion/39204/aturan-cara-menyisipkan-kode-program-di-diskusiweb

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Session Register di Linux

Teman,
Saya mau tanya,., saya membuat program PHP, dengan multi user, nah ketika saya upload diserver yg menggunakan Linux(Ubuntu) data session Login tidak muncul ketika sukses login, ketika mash di Window data session setelah login tersimpan dan bisa muncul pada halaman.Tolong pencerahannya ?

Tanggapan

  • coba tampilin contoh kodenya dulu kang...
    lalu framework apa yang dipake...
  • edited November 2011
    ini kodenya
    1. target_loginnya :
    <div class='geshi_syntax'><table><tr><td><div class='code'><pre class="php"><span class="sy1"><?</span>
    <span class="kw3">session_start</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="re0">$user_id</span><span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">[</span><span class="st_h">'user_id'</span><span class="br0">]</span><span class="sy0">;</span>
    <span class="re0">$mypass</span><span class="sy0">=</span><span class="re0">$_POST</span><span class="br0">[</span><span class="st_h">'mypass'</span><span class="br0">]</span><span class="sy0">;</span>
    <span class="re0">$encode_pass</span><span class="sy0">=</span><span class="kw3">base64_encode</span><span class="br0">(</span><span class="re0">$mypass</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="re0">$akses</span> <span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">[</span><span class="st_h">'akses'</span><span class="br0">]</span><span class="sy0">;</span>
     
    <span class="re0">$query</span> <span class="sy0">=</span> <span class="st0">"SELECT * FROM tabel WHERE user_id='<span class="es4">$user_id</span>' AND pass='<span class="es4">$encode_pass</span>' AND kd_akses='<span class="es4">$akses</span>'"</span><span class="sy0">;</span>
    <span class="re0">$hasil</span> <span class="sy0">=</span> <span class="kw3">mysql_query</span><span class="br0">(</span><span class="re0">$query</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="re0">$data</span> <span class="sy0">=</span> <span class="kw3">mysql_fetch_array</span><span class="br0">(</span><span class="re0">$hasil</span><span class="br0">)</span><span class="sy0">;</span>
     
    <span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'kd_akses'</span><span class="br0">]</span> <span class="sy0">=</span><span class="re0">$akses</span><span class="sy0">;</span>
    <span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'user_id'</span><span class="br0">]</span> <span class="sy0">=</span> <span class="re0">$user_id</span><span class="sy0">;</span>
    <span class="kw1">if</span><span class="br0">(</span><span class="re0">$data</span><span class="br0">[</span>kd_akses<span class="br0">]</span><span class="sy0">==</span><span class="st0">"A02"</span><span class="br0">)</span><span class="br0">{</span>
    <span class="kw3">header</span><span class="br0">(</span><span class="st0">"location:main/admin/index.php"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">(</span><span class="re0">$data</span><span class="br0">[</span>kd_akses<span class="br0">]</span><span class="sy0">==</span><span class="st0">"A03"</span><span class="br0">)</span><span class="br0">{</span>
    <span class="kw3">header</span><span class="br0">(</span><span class="st0">"location:main/user/index.php"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="br0">{</span>
    <span class="kw1">echo</span> <span class="st0">"Error"</span><span class="sy0">;</span>
    <span class="br0">}</span>
    <span class="sy1">?></span>
    2. Masuk kd_akses(A02) : header("location:main/admin/index.php");
    <span class="kw2"><?php</span>
    <span class="kw3">session_start</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="kw1">include</span> <span class="st0">"config.php"</span><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">(</span><span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'akses'</span><span class="br0">]</span> <span class="sy0">==</span> <span class="st0">"A02"</span><span class="br0">)</span> <span class="br0">{</span>
    <span class="kw3">header</span><span class="br0">(</span><span class="st0">"location:main/admin/index.php"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
    <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">(</span><span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'akses'</span><span class="br0">]</span> <span class="sy0">==</span> <span class="st0">"A03"</span><span class="br0">)</span> <span class="br0">{</span>
    <span class="kw3">header</span><span class="br0">(</span><span class="st0">"location:main/user/index.php"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
    <span class="sy1">?></span>
    3. Ini Masuk Index : header("location:main/admin/index.php");
    <span class="sy1"><?</span>
    <span class="kw3">session_start</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
     
    <span class="kw1">if</span><span class="br0">(</span><span class="sy0">!</span><span class="kw3">isset</span><span class="br0">(</span><span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'kd_akses'</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span><span class="br0">{</span>
    <span class="kw3">die</span><span class="br0">(</span><span class="st0">"Anda belum login"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
     
    <span class="kw1">if</span><span class="br0">(</span><span class="re0">$_SESSION</span><span class="br0">[</span><span class="st_h">'kd_akses'</span><span class="br0">]</span><span class="sy0">!=</span><span class="st0">"A02"</span><span class="br0">)</span><span class="br0">{</span>
    <span class="kw3">die</span><span class="br0">(</span><span class="st0">"Anda bukan admin"</span><span class="br0">)</span><span class="sy0">;</span>
    <span class="br0">}</span>
     
    <span class="kw1">include</span> <span class="st0">"utama.php"</span><span class="sy0">;</span>
     
    <span class="sy1">?></span></pre></div></td></tr></table></div>

    Ini ketika masih dijalankan di Windows pada halaman "utama.php" menampilkan nama User dengan echo"$user_id"; atau kode aksesnya tampil.
    tapi saya masukin di PC Server Linux Ubuntu, Session tersebut tidak bisa nampil.

    Saya tes di Hosting Linux bisa tampil dengan menambahkan file php.ini pada login.
    tapi di Lokal PC dengan OS Linux Ubuntu tidak tampil data sessionnya.

    Mohon solusinya para Master,
    Thx u


  • itu kok yang proses login ga da session_start() ?
    ngga include file yang mengandung session_start() juga?
  • edited November 2011
    Ada ko mas, cuma engga ke tulis. tetep juga engga tersimpan udh dikasih session jg.
    Maksudnya Include , apa mas ?
  • coba sebutin kondisi seting register globals di :
    - pc developer
    - server linux
    - server windows
  • Sudah terselesaikan, di linuxnya mesti register_globalnya di "On".

    Thx Teman semuanya
  • salah, pake banget !

    bukan register globals nya yg di ON -kan

    tapi script situ yg mesti diubah supaya tidak butuh lagi seting register globals ON

    mau ya, form yg semestinya pake POST dihajar lewat GET ?
    mau kalo ada form isian dihajar abis ama spammer?
    mau celah security kebuka lebar?
  • trus gmn donk ? solusinya ? apa yang mesti di tambahin?
  • sepanjang yg gw liat :

    - script atas gak ada masalah yg berhubungan dgn : "... menampilkan nama User dengan echo"$user_id"; atau kode aksesnya tampil ..."
    *yg bermasalah lain, yg di posting lain*

    - kesalahan cuma minor : masalah index array
    *coba nyalain seting error notice & warning, gak clean koding tuh*

    trus?
  • harusnya gmna ?
  • ya mana yg bermasalah?
  • "bukan register globals nya yg di ON -kan "

    jadi maslahnya dimana , coz saya sudah ON kan, kalo di Off itu session_ tidak tersimpan

  • edited November 2011
    ce spasi de ...
    . wrote:
    sepanjang yg gw liat :

    - script atas gak ada masalah yg berhubungan dgn : "... menampilkan nama User dengan echo"$user_id"; atau kode aksesnya tampil ..."
    *yg bermasalah lain, yg di posting lain*

  • MAksudnya Sensitif di Spasi ?
Sign In or Register to comment.