# How to validate username and password using .z.pw before a

**URL:** <https://forum.kx.com/t/how-to-validate-username-and-password-using-z-pw-before-a/11715>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [March 10, 2018, 10:40am UTC](https://forum.kx.com/t/how-to-validate-username-and-password-using-z-pw-before-a/11715 "2018-03-10T10:40:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liutongwei\_1](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@liutongwei\_1](https://forum.kx.com/u/liutongwei_1)\
**Post date:** [March 10, 2018, 10:40am UTC](https://forum.kx.com/t/how-to-validate-username-and-password-using-z-pw-before-a/11715/1 "2018-03-10T10:40:00Z")

</div>

Hi,

I am using KDB+ 3.5 2017.11.30 32bit and I want to&nbsp;validate username and password using&nbsp;.z.pw&nbsp;before a WebSocket connection.

When I try to open a WebSocket connection with&nbsp;&nbsp;ws://localhost:50150 as URL, and define .z.pw as&nbsp;

`.z.pw:{ show x; show y; 1b}`

it does open the connection but print

`q)`“”`

so this method does not work for me.

Is there any approach to prompt a dialog for users to enter their username and password when they open the HTML file using Chrome or other browsers? I don’t need to use&nbsp;ws://username:password@localhost:50150.

---

<div class="post-metadata">

**Author:** ![Joseph\_Edwards](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Joseph\_Edwards](https://forum.kx.com/u/Joseph_Edwards)\
**Post date:** [March 12, 2018, 9:55am UTC](https://forum.kx.com/t/how-to-validate-username-and-password-using-z-pw-before-a/11715/2 "2018-03-12T09:55:00Z")

</div>

Hi Tongwei,

Username/password combinations can be set for a KDB+ session using a password text file.

By using the -u flag when starting the session you want to connect to via a websocket, and passing to that flag the name of the validation text file, you’ll set up user validation for anyone trying to connect to that session.&nbsp;

This validation is automatically performed by .z.pw, and setting it as you have as .z.pw:{ show x; show y; 1b} will print off the username/password combinations used to connect to the session, although only in the case of a valid combination.&nbsp;

When attempting to connect to a session protected in this way, from a browser such as Chrome, with something like ws://localhost:50150, the user should automatically be prompted with popup to enter username/password.&nbsp;

Note that the password text file should contain combinations in the format:

user1:password1

user2:password2

.

.

Hope this helps,

Joseph

---

<div class="post-metadata">

**Author:** ![gkelly3](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gkelly3](https://forum.kx.com/u/gkelly3)\
**Post date:** [April 9, 2018, 3:27pm UTC](https://forum.kx.com/t/how-to-validate-username-and-password-using-z-pw-before-a/11715/3 "2018-04-09T15:27:00Z")

</div>

Hi Tongwei,&nbsp;

Like Joseph said, -u pointing to the password file is your best option for Validation.&nbsp;
