Does Date.today() return the current date based on the server's date? If so, how can I get the correct date for a user?
You can use ajax to send back the user date created by javascript on the client machine.
The best way is to ask the user what their timezone is. You can try to determine via software without asking them, but if the user has not set up their machine correctly you'll get an incorrect response. By asking you're giving them the choice to give a correct answer, or to lie to you if they are so inclined.
You might want to ask the same question over on SO's sibling User Interface site.
Related
I have a problem with getting User ID but I mean programmatically. Is any chance to get User's Live ID or something like that ? Because I want use trial experience with expiration time but is only one way how to do this. Storing all user's ID's and after installation check their identity. I don't want to use advertisement ID because it is not working in every case. Not every user is using this kind of ID.
So any ideas ?
You won't get any personal information without asking the user.
But the windows store features a trial mode with expiration. Check out the topic on MSDN.
Otherwise there is an overview on Idendity on Windows and you can use WebAuthenticationBroker on the Phone.
based on the following question/answer
CodeIgniter session class not working in Chrome
I had the problem where people are unable to login to my website from another country which is far from the US server. After searching online I've stumbled upon a suggestion which describes how the the problem is based on the difference between the server's timezone and the user's timezone. So, by extending the session_expiration I've managed to get around the problem and people are able to log in successfully.
My questions is whether the sess_time_to_update creates a new timestamp and it will logout the user because the new timestamp is in the wrong timezone? Do I have to make the new sess_time_to_update 17+ hours so that it covers the broadest range of timezones as explained in the question that I've linked. Is there some other way of storing the session at the user's browser based on their localtime (without asking them to choose timezones in the profiles and other sorts of user unfriendly schemes). I would like to have a 2h default session expiration time + the 800sec. update time. I'm not using the database to store the session and I would rather not use it.
The sess_time_to_update setting is how often the session details (such as last activity) are updated. The default is every 5 minutes (300 seconds) and a new session ID will be generated. This would reset the expiration date based on the sess_expiration setting.
I would suggest keeping the sess_time_to_update at the default (or lower) as that would keep the user session alive longer since the session expiration would keep getting reset. The only setting that may need to remain high would be sess_expiration, that is unless you can determine the users timezone.
There are a couple of ways you could try to determine the users timezone. One would be Javascript (Example: Client Side Timezone Offsetting) or you could try using PHP's GEOIP Methods.
I am playing with a timezones and I have a simple registration form. after user's registration, I would like to user display his current time, how to do that?
You can not do it only with Ruby, because such information isn't available on the server side.
1) If you know the user's location, you can do geo locating and determine the timezone. But it could be a problem if ip range you got from geo database has a few timezones.
2) Another solution, you can use javascript to help. So, with javascript you can calculate timezone and set it as cookie, and then access with Ruby from the request object. (How to get timezone with Javascript)
You could ask the user for their current timezone during registration and persist it with their user details.
ActiveSupport (included as part of the Rails API) has a great way to deal with timezones, you can convert the current time to a time in a different timezone using *in_time_zone*.
As an example
Time.now.in_time_zone("America/Guyana")
Time.now.in_time_zone(8)
Where the time_zone key can be found via this API document: http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
See TimeWithZone for more info, http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-i-in_time_zone.
Hey everyone, I am sorry if this question has already been asked/answered
But I have a Cocoa program that has different arrays of models. Each model hold just Strings and one Image. Archiving and Loading works great.
Each model represents a web account, that is, it holds the username and password, and some other information related to the website. Moving forward I would like to be able to update information in each model by accessing the information from the website. For example updating a balance ($). I am wondering if there is a way to do that programatically that is:
Automatically log into web account using the entered username, pass, and website url
Update the balance based on the information following log in.
Thanks for the help in advance!
Tamara
There is no single approach to log into any arbitrary website. You will need to know what the API for the given website is. If the website provides a web service to query things like balance, then you would connect using that web service (REST-based if at all possible; SOAP is more of a pain in Cocoa), and update your model based on the results. If the website provides no web service, then you would have to scrape through the HTML responses looking for what you want, and this is generally very complex and fragile. There is no general answer to this question; you'd have to know what form the website is in.
On another note, make sure that you are not storing user passwords in unencrypted files. User passwords on Mac should always be stored in Keychain. There are many posts on SO about how to best use Keychain.
Rob, isn't it possible to just look through the login page's html source and see what are the names of the fields for user and pass, and then just send a POST request to that page from code ?
Is there a direct API to get the currently logged in user's name with the domain? So, it would return something like "domain\user" when a machine is on the domain, but at the same time it would return "user" when the machine is not on the domain? If there's not, what's the best way to get this information?
I noticed there's a LookupAccountName function - would that be the right direction to take?
Try GetUserNameEx(). It supports various name formats.