Welcome Guest, Not a member yet? Register   Sign In
Depractaion request warning
#1

(This post was last modified: 04-19-2024, 10:14 PM by ozornick.)

I am queite new to codeigniter and having some issues with the request object.

I am trying to pass some tokens from before filter to the request object but getting some depracation warning when trying to access it from controller

```
// before filter
$request->decodedToken = $decoded;
```
```
// after filter
   public function logout()
   {
       $originalToken = $this->request->originalToken ?? null;
   }

```

WARNING - 2024-04-19 12:40:09 --> [DEPRECATED] Creation of dynamic property CodeIgniter\HTTP\IncomingRequest::$originalToken is deprecated in APPPATH/Filters/AuthFilter.php
Reply
#2

You can't do that. Use sessions, cookies. Strangely, it seems that the request cannot store parameters. kenjis will complete the information
Simple CI 4 project for beginners codeigniter-expenses
Reply
#3

PHP community decided that Creation of dynamic property is a bad practice.

Quote:The core problem is that reading from a non-existing property issues a diagnostic that makes the issue immediately apparent, while writing to a non-existing property is entirely silent. PHP gives no indication whatsoever that the programmer has made a mistake.
See https://wiki.php.net/rfc/deprecate_dynam...motivation

So you should not use it.

If you use class properties, you should define them in the class.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB