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

how to regenerate different session id??

Hi all! i have a problem with session....i use Redis to store session's user... ex: i have two user: user1, user2. for user1 have session_id(value)=a80mr3r18n73h47mlnnviqhbu2 and (key) mykey_a80mr3r18n73h47mlnnviqhbu2 is stored redis.

i want to regenerate session id for each user and the sessions, keys are different.

ex: user2: session_id(value)=nm4mr901nn73h47ouinviqhb49 and (key) mykey_nm4mr901nn73h47ouinviqhb49

so, how can i do it??? or have a function??? thank so much!

public regenerateId ([unknown $deleteOldSession])

https://docs.phalcon.io/en/latest/api/Phalcon_Session_Adapter.html



4.3k

thank you! but regenerateId() function will delete old session

public regenerateId ([unknown $deleteOldSession])

https://docs.phalcon.io/en/latest/api/Phalcon_Session_Adapter.html

@phamdien: you can supply first argument as false, since default is true (deleteOldSession)

From Zephir codebase:

    public function regenerateId(bool deleteOldSession = true) -> <Adapter>
    {
        session_regenerate_id(deleteOldSession);
        return this;
    }