We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Why do I need to specify an uniqueId while initializing \Phalcon\Session\Adapter\Redis ?

use Phalcon\Session\Adapter\Redis;

 $session = new Redis([
     'uniqueId'   => 'my-private-app',
     'host'       => 'localhost',
     'port'       => 6379,
     'auth'       => 'foobared',
     'persistent' => false,
     'lifetime'   => 3600,
     'prefix'     => 'my_'
     'index'      => 1,
 ]);

According to the sample code above, I need to specify an uniqueId for the session. but it made something a little terrible in my code for some reason. I looked over the data has been storaged in redis server and I did't understand why the uniqueId was needed. What should happen if I specify the uniqueId as an empty string ?



85.5k

if you have 2 application on the same server, to tell them apart. I think ...

I thought it was but the uniqueId is not for the keys in redis. It was only added before every item of the array.


127.0.0.1:6379[1]> keys *
  1) "_PHCRns_s7do7vvcb3dhkblgnd5ketco590"
  2) "_PHCRns_s6pspriiskf2itkel56qo1jvjb2"
  3) "_PHCRns_s217nrnvtug9pflrefmtnm2pot6"
  4) "_PHCRns_s7ndmlm4pr2cqi76tkpp9qo95a4"
  5) "_PHCRns_sej5pd580uttv0md0kr7rtfkmn3"
  6) "_PHCRns_sptj6cjms86coek2ndpcmb9tjr2"

127.0.0.1:6379[1]> get _PHCRns_s7do7vvcb3dhkblgnd5ketco590
"csrf-token|s:32:\"48c676a64c2caf2cbc7b9c6e74f615bc\";"

if you have 2 application on the same server, to tell them apart. I think ...