Aynı dosyadan iki seans Yazma (PHP)

1 Cevap php

Ben mümkün yönetici backend bir fontend kullanıcı olarak oturum için yapmak istiyorum. Şu anda ben iki seans (farklı adlarla oturumlar), yönetici için bir ve önyüz için birini kullanıyorum.

Bu, ilk oturumda yazmak kapatın ve sonra yeni bir oturum açmak mümkün mü?

Bu benim çalıştı ancak başarısız oldu ne basitleştirilmiş bir versiyonu:

session_name('admin_session');
session_start();
// use first session without generatring any output
session_close();

session_name('frontend_session');
session_start();
// use the second session

Teşekkürler.

1 Cevap

Ben geçmişte bir "kullanıcı" geçmek için bir yönetici için tesis sağlamıştır.

I did this by serializing the admin user's $_SESSION and then storing that string as $_SESSION['adminData'] before overwriting all the other session vars with those of the user he was logging in as, and redirecting to the main page. The only different feature on the main page was an if test against $_SESSION['adminData'] that provided a "revert to admin" link... but to all intents and purposes, the administrator was now logged in as that user. On clicking the "revert to admin" link, the code logic simply unserialized $_SESSION['adminData'].