Session and Cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Session and Cookies

Post by waqas_punjabian »

Hi all,

please tell me one thing about session:

I've found if a user will disable Cookies in his Browser (FireFox,IE7) then it directly affects session, means I cannot create a session if user disable the cookie. Someone told me to turn off this option in php.ini

session.use_cookies = 1 (turn it to '0')

It worked fine, but the thing is, we have some other sites on this server as well. So is there a way to turn this option off using some php code or function?

or is there a way to separate the session functionality from cookie involvement.

furthermore, I use session in this way:

Code: Select all

$_SESSION['user_id'] = "123";
regards,

Waqas
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I believe it is the setting "session.use_only_cookies" that you might want to look at. If it is set to "1" then sessions only work with cookies enabled.
(#10850)
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Post by waqas_punjabian »

thanks for your reply,

yes it may be "session.use_only_cookies". But my problem is still their: can I do this setting using my php code ?

or is there any other way to create the session? (that will not be interfered by cookie disabling)
tansoft
Forum Newbie
Posts: 12
Joined: Sun Jul 29, 2007 1:04 am

check this one

Post by tansoft »

You can set it in .htaccess

php_flag session.use_only_cookies off

or you this in your php code.

ini_set('session.use_only_cookies', false);
Post Reply