2

after user loging to the system(Auth::attempt success)

how to add additional data to the Auth session and remove additionally added variables
without logout user ? (I mean without calling Auth::logout();)

is there a laravel methods to do that ?

updated : found a way to add but how to remove added variable ?

Auth::user()->setAttribute('key','value');
//Auth::user()->unsetAttribute('key','value'); ????? how to remove
return Response::json(Auth::user());
2
  • i don't think this will work cause that attribute you have setted do not will persist through the session Commented Jul 14, 2016 at 19:51
  • where to add this Auth::user()->setAttribute('key','value'); code to work Commented Oct 8, 2020 at 6:52

1 Answer 1

3

Simple answer for this, you can unset variables, attributes etc, using php's unset function.

try this

 unset(Auth::user()->key);

check this http://php.net/manual/en/function.unset.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.