En iyi uygulama - başka bir kullanıcının oturumunu güncellemek?

0 Cevap php

Benim kullanıcıları siteme giriş yaparken birçok web uygulamalarında olduğu gibi, ben site işlevsellik erişim izinlerini kontrol birkaç oturum değişkenleri ayarlayın.

Bir kullanıcı bu izinlere bir değişime neden olacak bir eylem üstlenir zaman, ben normal işlem akışının bir parçası olarak oturum değişkenleri güncellemek.

Ama bazen bir kullanıcının oturum başka bir kullanıcının eylemleri göre güncelleştirilmesi gerekiyor. Örneğin, bir moderatör bir kullanıcının izinlerini yükseltir. Moderatör kullanıcının oturum alanı erişimi yok, bu yüzden normal güncelleme işlevleri etkilenen kullanıcının çalıştırılamaz.

Ben başka bir kullanıcının oturumuna bir güncelleştirme zorlayarak birkaç yollarını kabul var, ama hepsi sakıncaları vardır:

  • I could search for and delete their session from the sessions table, but this requires a full table scan (where sessdata like '%user_id%'), and it could cause the loss of content that the affected user may be engaged in generating.
  • I could force a session update periodically, such as when sess_time_to_update is triggered. But there is no guarantee that this will transpire prior to the user attempting to access the functionality for which the update is needed.
  • I could run a complete series of variable updates on every page load, but the whole point of maintaining a session is to avoid that overhead.
  • I could set a flag indicating the need for a session update, but that signal would have to be interrogated at every page execution, and in every controller. (I know that I could extend CI_Controller as MY_Controller, but I don't want to do that)
  • I'm already sending the user an email notifying them of the change in permission, and it's easy enough to make them click a session update link (or even log out and log back in). But there's no guarantee they are going to even read beyond the subject line, let alone actually click the link.

Yani eksik bir şey var mı? Ben yoksa sihirli bir mermi arıyorum?

Ben kullanıyorum ne çünkü (ben CodeIgniter ile bu etiketlediniz unutmayın, ve CI-spesifik teknik detayları başvuru yaptı., Bu CI-spesifik (hatta bir PHP-spesifik) sorunu değildir, dedi ki. )

Yardımın için teşekkürler!

0 Cevap