Failed retrieving session from SG with PHP

Ok so I have server running

I create user via CLI (it works)

curl -vX POST -H 'Content-Type: application/json' -d '{"name": "test", "password": "123456"}' :4985/sync_gateway/_user/
  • works ok

  • login via CLI

curl -vX POST -H 'Content-Type: application/json' -d '{"name": "test", "password": "123456"}' :4984/sync_gateway/_session

works also OK, I retreived

*   Trying ::1...
* Connected to  (::1) port 4984 (#0)
> POST /sync_gateway/_session HTTP/1.1
> Host: :4984
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 38
* upload completely sent off: 38 out of 38 bytes
< HTTP/1.1 200 OK
< Content-Length: 103
< Content-Type: application/json
< Server: Couchbase Sync Gateway/1.2.0
< Set-Cookie: SyncGatewaySession=724a41523848f38971d09319d819678734107201; Path=/sync_gateway; Expires=Thu, 14 Jul 2016 14:26:36 GMT
< Date: Wed, 13 Jul 2016 14:26:36 GMT
* Connection #0 to host  left intact
  • login with postman body response (name is missing)
  "authentication_handlers": [
  "ok": true,
  "userCtx": {
    "channels": {
      "!": 1,
      "*": 1
    "name": null
  • response headers (note that Set-Cookie param is missing)
Content-Length →107
Content-Type →application/json
Date →Wed, 13 Jul 2016 14:30:17 GMT
Server →Couchbase Sync Gateway/1.2.0

I have the same response from Coucbase GW, when I make server(PHP) POST request to Couchbase GW ( I’m using )

  • please help

The response with the null name value looks like the expected response if (a) you’ve got the GUEST user enabled, and (b) you aren’t sending any authentication credentials on the request (i.e. no session token or basic auth credentials).

Hey, thank you for quick response, could you please give a good material for register/authenticate user?

Pretty basic use scenario:
(client) -> (server) -> (couchbase)
(couchbase -> (server) -> (client)

PS: on server is PHP, but do I register/auth user from server, directly to couchbase server or couchbase GW

The Sync Gateway user authentication docs are here:

For the simple case, the usual approach is to use basic auth to authenticate against Sync Gateway. More advanced cases are described in the link above.