James142 Posted June 12, 2011 Report Share Posted June 12, 2011 Hello. I have spent a while searching for a JavaScript code to remember what a user has clicked on in their last visit on the internet for what I am looking for what I need but I cant find it. So I was wondering if anyone here has ever came across such a code online before? To make things a little clearer, what I am looking for is a JavaScript code that will save information on a cookie about what link a user has clicked on in their last visit and keep redirecting them to that link everytime they visit the page. So if they go to www.yoursite.com and click on a link that says Link-1, it will redirect them to www.yourwebsite.com/link-1 everytime they visit www.yourwebsite.com/ I will appreciate any replays. Kindest Regards, James Quote Link to comment Share on other sites More sharing options...
James142 Posted June 12, 2011 Author Report Share Posted June 12, 2011 [Comment Removed] Quote Link to comment Share on other sites More sharing options...
vader21 Posted June 20, 2011 Report Share Posted June 20, 2011 What exactly would you like to save sir? I know you said what the user has clicked but give us a little more information please.(At least for me) Quote Link to comment Share on other sites More sharing options...
Tom Posted June 20, 2011 Report Share Posted June 20, 2011 Why JavaScript? Easier with php! $_SERVER variables for the request URL, then look up php cookie functions. Quote Link to comment Share on other sites More sharing options...
vader21 Posted June 20, 2011 Report Share Posted June 20, 2011 That is correct and cookies have a limit! also remember JavaScript can be disabled! Quote Link to comment Share on other sites More sharing options...
James142 Posted June 20, 2011 Author Report Share Posted June 20, 2011 What I was trying to do was to store the language the user selected on his first visit to the website (by clicking on a flag) so on his next visit their browser will automatically redirect them to their selected language. I found a JavaScript code that stores the language you have selected in a cookie. Unfortunately at the time I though you could only do this with JavaScript and I had no idea you could so it with php. So you guys are saying that I can do it with php and if so would this information http://www.w3schools.com/php/php_cookies.asp be useful? Thanks Guys, James Quote Link to comment Share on other sites More sharing options...
vader21 Posted June 20, 2011 Report Share Posted June 20, 2011 That information would be useful yes! :)but if you want i can try to code this for you! Oh by the way, how are you doing the translator? are you making individuals pages for it? or using GOOGLE API? 1 Quote Link to comment Share on other sites More sharing options...
James142 Posted June 20, 2011 Author Report Share Posted June 20, 2011 That information would be useful yes! :)but if you want i can try to code this for you! Oh by the way, how are you doing the translator? are you making individuals pages for it? or using GOOGLE API? I have individuals pages made out for it. If you wouldn't mind having a shot at coding this, i would be very grateful for it. Regards, James (Sorry if the above sentences made no sense, I only woke up about an hour ago ) Quote Link to comment Share on other sites More sharing options...
Tom Posted June 20, 2011 Report Share Posted June 20, 2011 The example is pretty much exactly what you need to do. Make sure to give it a completely unique name - easies to add a prefix, i.e. flyaero_lang Cookies can also be disabled, so add a note to tell users that if they have cookies disabled they will be required to select their language each time. Another way you could do it is assuming based on their browser/system language. If their language doesn't match one of yours you could default to English, or let them choose again. 1 Quote Link to comment Share on other sites More sharing options...
James142 Posted June 20, 2011 Author Report Share Posted June 20, 2011 How you guys can remember all this amazes me Ill have a go with all this in localhost after I finish a "module" I am working on. Quote Link to comment Share on other sites More sharing options...
vader21 Posted June 20, 2011 Report Share Posted June 20, 2011 No problem sir. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted June 20, 2011 Report Share Posted June 20, 2011 You could also add a field "lang" to the pilot table. This would remain even if the pilot deletes his/her cookies or moves to a different computer. It would be part of the Auth::$userinfo then. as in...... if(AUTH::$userinfo->lang == 1) { //Set language #1 stuff here } elseif(AUTH::$userinfo->lang == 2) { //Set language #2 stuff here } else { //Set default language stuff here } Quote Link to comment Share on other sites More sharing options...
James142 Posted June 20, 2011 Author Report Share Posted June 20, 2011 You could also add a field "lang" to the pilot table. This would remain even if the pilot deletes his/her cookies or moves to a different computer. It would be part of the Auth::$userinfo then. as in...... if(AUTH::$userinfo->lang == 1) { //Set language #1 stuff here } elseif(AUTH::$userinfo->lang == 2) { //Set language #2 stuff here } else { //Set default language stuff here } That would be cool cause a couple of my pilots have multiple computers. But does that mean I have to add that code to every page? Regards Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted June 20, 2011 Report Share Posted June 20, 2011 Not if you do it correctly. I am not sure how the OP is doing the translating but you can use this in the header or layout template. Then set a variable or point the templates into a new direction or whatever you can imagine. I use this type of code for a lot of things. Quote Link to comment Share on other sites More sharing options...
James142 Posted June 21, 2011 Author Report Share Posted June 21, 2011 Not if you do it correctly. I am not sure how the OP is doing the translating but you can use this in the header or layout template. Then set a variable or point the templates into a new direction or whatever you can imagine. I use this type of code for a lot of things. Ok thanks I will have a shot at it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.