:relfileprefix: ../../../
[#6E5903AAEC331ED93BA399897FF85D798D79CD68]

= Function url_base::set_password

pass:v,q[Set the password.]


== Synopsis

Declared in header `</boost/url/url_base.hpp#L730[boost/url/url_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/url_base.adoc[url_base]&
set_password(string_view s);
----

== Description

pass:v,q[This function sets the password in] pass:v,q[the userinfo to the string.]
pass:v,q[Reserved characters in the string are]
pass:v,q[percent-escaped in the result.]
[NOTE]
pass:v,q[The interpretation of the userinfo as]
pass:v,q[individual user and password components]
pass:v,q[is scheme-dependent. Transmitting]
pass:v,q[passwords in URLs is deprecated.]

=== Example
[,cpp]
----
assert( url("http://user@example.com").set_password( "pass" ).encoded_userinfo() == "user:pass" );
----

=== Postconditions
[,cpp]
----
this->has_password() == true && this->password() == s
----

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[Calls to allocate may throw.]

=== BNF
[,cpp]
----
userinfo      = [ [ user ] [ ':' password ] ]

user          = *( unreserved / pct-encoded / sub-delims )
password      = *( unreserved / pct-encoded / sub-delims / ":" )
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1[            3.2.1. User Information (rfc3986)]



== Return Value

* `` 


== Parameters

|===
| Name | Type 

| *s*
| `string_view`

|===



