Maybe it's a family emergency, or maybe a pal in a distant city needs help. Better yet, maybe an incredible last-minute cruise deal just arrived in your inbox. Whatever the reason, booking a flight just before it's due to take off is often possible – assuming some tickets are still up for grabs on the flight you're eyeing. Buying a ticket within the two-hour window before departure generally has to happen at the airport, and it might earn you some extra attention from the TSA. All that takes time, so head straight for the airport as soon as possible.

What Are My Options?

The most important thing to remember when trying to book a last-minute flight is that each airline has its own policies. One carrier may allow passengers to book flights online with less than two hours' lead time before departure, while others may not allow any bookings at all within that window. But it's common for domestic airlines to accept online flight purchases up to two hours before departure, and then only at the airport ticket counter after that. The best thing to do is make your way to the airport immediately. Try to book a ticket on your phone during the trip (assuming someone else is driving, of course); if that's not possible, head straight to the ticket counter upon reaching the airport.

Have a change of plans during a layover or when you're already at the gate? Go to the airline help desk within the terminal or ask the agents working behind the desk at your gate to assist in making a last-minute flight booking. Depending on airline policy, it may be necessary to go back down to the ticket counter and then come back through the security screening checkpoint.

If you need last-minute tickets because of a family emergency, call the airline's reservations line. Some companies offer discounts on published fares for travelers in certain emergency circumstances.

What Should I Know?

Hotels often slash prices on last-minute bookings. After all, it's better to get a paying customer into that room, even at a discounted rate, than to leave it empty. Unfortunately, the airlines don't follow the same principle when it comes to pricing last-minute flights. Don't expect to get a deal on a ticket within two hours of departure. In fact, your day-of price may be double what other passengers on the same flight paid for their tickets.

If the quest to buy a ticket close to the departure time is successful, check the boarding pass carefully. The TSA code SSSS may be printed there in large letters. It stands for Secondary Security Screening Selection, and passengers whose boarding passes are printed with this code undergo more in-depth screening than others. The TSA may assign this code to travelers who book last-minute flights because it doesn't have enough time to pre-check those passengers' names against watchlists and other databases. If SSSS is printed on your boarding pass, expect TSA agents to pull you aside for thorough screening. Agents may even open suitcases and inspect every item. That process may be frustrating when your flight is getting ready to leave, but remaining calm and cooperative is the best way to quickly get past security.