Apple has released a software update after complaints that iPhones and iPads were secretly recording locations.
The problem came to light when security researchers found a hidden file on the devices containing a record of everywhere they had been.
Used with certain software, the file could generate a map of all a person's movements with the phone.
Apple denied that it has used the information to track user location and blamed a bug in the software.
The update, which is available through the iTunes store, cuts the amount of stored data to just a week and no longer transfers it to the owner's computer when the phone is connected.
And if users disable the location services setting on their iPhone or iPad, it will stop collecting data completely.
Permission for the tracking was given by users, albeit hidden away in the terms and conditions for the iTunes store.
The data was logged via cell towers and wi-fi access points.
The storage of the data was brought to light in a blog post from researchers Alasdair Allan and Peter Warden.
At the time Mr Allan said that he did not think there was "any sort of conspiracy going on".
"However, we're both worried about this level of detailed location data being out there in the wild. While the cell phone operators already have this data, it takes a court order to obtain it from them. You can now do the equivalent by simply leaving your iPhone in a bar. That doesn't seem right to me."
In response Apple said: "The iPhone is not logging your location, rather it's maintaining a database of wi-fi hotspots and cell towers around your current location, some of which may be located more than 100 miles away from your iPhone to help your phone rapidly and accurately calculate its location when requested."
It said it was collecting some location data with the goal of providing iPhone users with an "improved traffic service in the next couple of years".
Many smartphone owners chose to voluntarily opt in to location tracking services such as Foursquare and Mobile Me but there is rising concern about how companies use such data.
Later this month Apple and Google are due to testify at a US senate hearing on mobile privacy as the firms come under increasing pressure to reveal how they collect and store location data.
Smartphones running Google's Android operating system also store data but it is an opt-in service, according to the firm.
A lawsuit has been filed against Apple in Florida last week, accusing the firm of violating privacy laws. Two women in Michigan are also suing Google over data collected by Android devices.