p4 login


Log in to the Perforce service by obtaining a ticket.


p4 [g-opts] login [-a -p] [-h host] [user]
p4 [g-opts] login [-s]


The p4 login command authenticates a user and creates a ticket that represents a session with Perforce. Once authenticated, a user can access the shared versioning service until either the ticket expires or until the user issues the p4 logout command.

By default, tickets are valid for 12 hours.

To obtain a ticket valid for all IP addresses (for instance, to use Perforce simultaneously on more than one workstation), use p4 login -a. Users with tickets that are valid for all IP addresses still consume only one Perforce license.



Obtain a ticket that is valid for all IP addresses.

-h host

Request a ticket that is valid for the specified host IP address.


Display the ticket, rather than storing it in the local ticket file.


Display the status of the current ticket, if one exists.


See “Global Options”.

Usage Notes

Can File Arguments Use Revision Specifier?

Can File Arguments Use Revision Range?

Minimal Access Level Required




  • The default timeout value of 43200 seconds (12 hours) is defined on a per-group basis in the p4 group form.

  • To create tickets that do not expire, set the timeout value to unlimited in the p4 group form.

  • By default, after three failed login attempts, a user must wait 10 seconds before logging in again. Perforce superusers can control the number of login attempts by setting the dm.user.loginattempts configurable.

  • To extend a ticket's lifespan, use p4 login while already logged in. Your ticket's lifespan is extended by 1/3 of its initial timeout setting, subject to a maximum of your ticket's initial timeout setting.

  • Perforce superusers can obtain login tickets for users other than themselves without entering passwords. Non-superusers who attempt to log in as other users must use the p4 -u username login form of the command, and correctly supply the other user's password.

  • Tickets are stored in the file specified by the P4TICKETS environment variable. If this variable is not set, tickets are stored in %USERPROFILE%\p4tickets.txt on Windows, and in $HOME/.p4tickets on other operating systems.

  • The -h option causes the service to issue a ticket that is valid on the specified host IP address. This option is typically used with -p to display a ticket that can subsequently be used on another machine.

  • In replicated environments, logging in to the master server does not log you in to any replica servers.


p4 login

Prompt the user for a password; if the password is entered correctly, issue a ticket valid on the user's machine.

p4 -u builder login -a

Attempt to log in as user builder; if the password is entered correctly, issue a ticket valid on all machines.

Related Commands

To end a login session

p4 logout

To display tickets

p4 tickets