Jump to content

JavaScript Help


James142

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :P)

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

Guest lorathon

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
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest lorathon

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...