How can I get current user id through ajax?

Posted in CategoryLaravel
  • B
    Bob 8 months ago


    I am following this article 

    It's been very helpful. Thank you for the tutorial. However, I want to get current user id and save the id to the database. How can I do it?

    Thank you in advance :D

  • H
    Hardik Savani 8 months ago

    Sure you can get current login user id using auth(). You can get user id in your controller this way:

    $userId = auth()->user()->id;

    Let me know if it is work.

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *