Jump to content

Lang selection->how to store the lang id...


mmarif4u

Recommended Posts

Hi to all.

I am working on a site,its in english.now my company decided to make another version for the site.

Everything i already make and working fine.

Just the problem is lang switching.

for example if user select the BM lang and then he want to login to the user area,so how can the script will recognize that user choses the BM lang.

I have 2 ideas about this:

1-store in db and then retrieve it later in login script.

2-store in session

 

About 1st option i am not sure,bcz at the same moment alot of user will access site,and b4 user login cannot store that to specific user id.

Now 2nd option is a bit simple but i need some more information,how to do it and will it be stable in future and secure.

 

Thanks in advance for any comments.

Link to comment
Share on other sites

I would use a combination of Cookies and Session variables. You will never know the correct language the first time a user visits your site, thus the login page must hav a selection. BUt, once a cookie is set you can use that whenever the user revisits your site.

 

However, if the user has Cookies disabled you can use Session data to at least remember their language for each visit.

 

Saving the language selection to the database is an optioin, but it will not remember their selection until after they log in. So, you could use the DB value as a third parameter if you wish but I think it's use would be limited - i.e. it would only take effect once they log in and you would either need to query the DB on every page or save the value to a session variable anyway.

 

Take a look at the script I posted in this thread: http://www.phpfreaks.com/forums/index.php/topic,159661.0.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.