# Integrate mattermost in a django project with existing users by setting mmauthtoken cookies

**URL:** <https://forum.mattermost.com/t/integrate-mattermost-in-a-django-project-with-existing-users-by-setting-mmauthtoken-cookies/5976>\
**Category:** Troubleshooting\
**Created:** [October 23, 2018, 7:31am UTC](https://forum.mattermost.com/t/integrate-mattermost-in-a-django-project-with-existing-users-by-setting-mmauthtoken-cookies/5976 "2018-10-23T07:31:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dejavu88](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dejavu88](https://forum.mattermost.com/u/dejavu88)\
**Post date:** [October 23, 2018, 7:31am UTC](https://forum.mattermost.com/t/integrate-mattermost-in-a-django-project-with-existing-users-by-setting-mmauthtoken-cookies/5976/1 "2018-10-23T07:31:27Z")

</div>

I wanted to integrate mattermost in my existing django web project and trying to login by using separate database table for username and password for mattermost that maps to my project users.  
I am using the python driver for mattermost and trying use a single login system for better user experience but I unable to set the cookies. I have found different post regarding this [using custom oauth](https://forum.mattermost.com/t/sso-using-a-custom-oauth/677) and [Login to Mattermost from browser by skipping the login form](https://forum.mattermost.com/t/solved-login-to-mattermost-from-browser-by-skipping-the-login-form/3468) but was not able to follow the instructions.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [October 23, 2018, 5:54pm UTC](https://forum.mattermost.com/t/integrate-mattermost-in-a-django-project-with-existing-users-by-setting-mmauthtoken-cookies/5976/2 "2018-10-23T17:54:16Z")

</div>

Hi @dejavu88,

There are two cookies that need set to login without a password and username. Here’s an example of how to set them:

```auto
setcookie('MMUSERID', '<user id from database>', time()+606024*30, ‘/’, ‘.yourdomain.com’, true, true);
setcookie('MMAUTHTOKEN', '<Authentication Token Value>', time()+606024*30, ‘/’, ‘.yourdomain.com’, true, true);

```

Replace `<user id from database>` and `<Authentication Token Value>` with their respective values for that user. You can get both of these values with a database query, or by using the authentication instructions for the [Mattermost API.](https://api.mattermost.com/#tag/authentication) Is this what you’re looking for?

---

<div class="post-metadata">

**Author:** ![dejavu88](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dejavu88](https://forum.mattermost.com/u/dejavu88)\
**Post date:** [October 30, 2018, 5:56am UTC](https://forum.mattermost.com/t/integrate-mattermost-in-a-django-project-with-existing-users-by-setting-mmauthtoken-cookies/5976/4 "2018-10-30T05:56:41Z")

</div>

@amy.blais thanks !! This is what I was looking for.
