Severity: 8192
Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 113
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 280
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 145
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 223
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 303
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 344
Severity: 8192
Message: setcookie(): Passing null to parameter #7 ($httponly) of type bool is deprecated
Filename: core/Input.php
Line Number: 410
Web Storage bize veri depolamak için 2 seçenek sunmakta. Bu yazıda bu seçeneklerden ikincisi olan Session Storage'dan (Geçici Depolama) bahsedeceğim. Session Storage mantığı tıpkı session cookies (geçici çerezler) gibidir. Veriler bilgisayarda (tarayıcıya göre konum değişebilir) depolanır. Tarayıcı kapanana kadar veya sekme kapanana kadar veriler kaybolmaz. Session Storage özelliği Javascript ile kullanılır. Depolama işlemleri yapılırken HTML5 ile birlikte hazır olarak gelen sessionStorage nesnesinden yararlanılır.
Session Storage'a Veri Ekleme
Session Storage'a veri eklemek için sessionStorage nesnesinin setItem() metodu kullanılır. Çerezlerde olduğu gibi yine key-value tanımlaması geçerlidir.
Kullanımı ve Örnek
sessionStorage.setItem(key, value);
sessionStorage.setItem("isim","Hakan");
key: Değerin hangi isimle depolanacağını belirtir.
value: Depolanacak değeri belirtir.
"isim" değişkenine "Hakan" değerini atayıp veriyi depolar. Depolanan veri bilgisayarda tutulur. Tarayıcılar sayesinde hangi verilerin depolandığını görmek mümkündür. Örneğin; Chrome ile "Öğeyi Denetle" seçeneğinden "Resources" sekmesine girip, soldaki menüden Session Storage'a tıklandığında hangi sitede hangi verilerin depolandığı karşınıza çıkacaktır.
Session Storage'dan Veri Okuma
Session Storage'dan veri okumak için sessionStorage nesnesinin getItem() metodu kullanılır.
Kullanımı ve Örnek
sessionStorage.getItem(key);
sessionStorage.getItem("isim");
key: Hangi depolanan değerin okunacağını belirtir.
"isim" değişkenindeki veriyi okur. İlk örneğe göre "isim" değişkeninde "Hakan" depolandığına göre okunan değer de "Hakan" olacaktır.
Session Storage'dan Veri Silmek
Session Storage'dan veri silmek için sessionStorage nesnesinin removeItem() metodu kullanılır.
Kullanımı ve Örnek
sessionStorage.removeItem(key);
sessionStorage.removeItem("isim");
key: Hangi depolanan değerin silineceğini belirtir.
"isim" değişkenindeki veriyi siler. İlk örneğe göre "isim" değişkeninde "Hakan" depolandığına göre silinen değer de "Hakan" olacaktır.
Session Storage'daki Tüm Verileri Silmek
Session Storage'daki tüm verileri silmek için sessionStorage nesnesinin clear() metodu kullanılır.
Kullanımı
sessionStorage.clear();
Önizlemeye tıklayarak Session Storage'ın nasıl çalıştığını daha kolay anlayabilirsiniz. İsminizi girip kaydettiğinizde veriler Session Storage'a depolanır, alt satırda Session Storage'a depoladığınız veri okunur. Veriyi silmek istediğinizde sil butonuna tıklayın. Tarayıcıyı veya sekmeyi kapatıp sayfayı tekrar açtığınızda verinin kaybolduğunu göreceksiniz.
YORUMLAR