Extending Login - User

Permalink
I am looking at rewriting my website and would love to start out with 5.7. I am currently using 5.5 and started my new development on 5.6. I have extended the User model so that when a user is logged on it saves a cookie to the database

/concrete/core/models/user

CheckLogin
//Next Lines are for inserting SQL
                                        $cookieID=$_COOKIE['CONCRETE5'];
                                        $userID=$this->getUserID();
                                        $q1 = "INSERT INTO ci_cookie (id, uID) VALUES ('$cookieID', '$userID')";
                                        $db->query($q1);


I have copied Core/Models/User

to /Models and extended it using..

<?php defined('C5_EXECUTE') or die("Access Denied.");
        class User extends Concrete5_Model_User {


I am then using Codeigniter on the other side to grab the uID and do somethings there.

Is there an easy way to do similar in 5.7 or should I just keep going with 5.6.

jgalat
 
Mnkras replied on at Permalink Reply
Mnkras
5.7 has support for manipulating sessions and cookies built in. You can basically just override the class and it will takeover everything, its a really simple API.

Mike
jgalat replied on at Permalink Reply
jgalat
Thank you for the quick response .. and any additional help is appreciated. Here is what I think I understand but I don't know if I am looking in the right place or if there is just inconsistencies in what I am reading.

1. I have copied /concrete/src/cookie/cookie.php to /application/bootstratp/src/my/cookie/cookie.php

2. I have gone into /application/bootstrap/app.php and added

Core::bind('\Concrete\src\Cookie\Cookie'){
    return new \Application\bootstrap\Src\My\Cookie\Cookie
});


which I know is wrong!

3. Then in my new copied Cookie.php I have changed to

<?php
namespace Application\bootstrap\src\My\Cookie\Cookie;
use Symfony\Component\HttpFoundation\Cookie as CookieObject;
use Request;
class Cookie extends \Concrete\src\Cookie\Cookie
{ .....


Things are broken at the app.php for sure but I am not sure about the other code either.
Mnkras replied on at Permalink Reply
Mnkras
Just by glancing at this, instead of 'src', try using 'Core'
jgalat replied on at Permalink Reply
jgalat
Do I have to do anything in app.php to use the override.
jgalat replied on at Permalink Reply
jgalat
After further review here is what I have but it is not working. Concrete is not using my Cookie.php

1. Copied /concrete/src/Cookie/Cookie.php to /application/bootstrap/src/my/cookie

2. In /application/bootstrap I have modified app.php to read

Core::bind('\Concrete\Core\Cookie\Cookie',function(){
    return new \Application\bootstrap\Src\My\Cookie\Cookie();
});


3. In my Cookie.php have modified to

<?php
namespace Application\bootstrap\src\My\Cookie\Cookie;
use Symfony\Component\HttpFoundation\Cookie as CookieObject;
use Request;
class Cookie extends \Concrete\Core\Cookie\Cookie { ....


When the cookie is created I have added my code to write the cookie to the database but it is not working.