PHP Sessions

This is a discussion on "PHP Sessions" within the PHP Forum section. This forum, and the thread "PHP Sessions are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 24th, 2005, 09:18
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
PHP Sessions

i have two sites running on the same server, one at www.bpcu.co.uk and one in www.bpcu.co.uk/forum - however, they have different logins, and if you login to one, it completely ruins the other one because it's trying to use the other one's session variables... how can i stop this? can you restrict session variables to one folder? or something lol

any help would be much appreciated
Reply With Quote

  #2 (permalink)  
Old Aug 24th, 2005, 21:41
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
The default session for the session.cookie_path is /, which means that they cookie issued by one application will be passed to the other. And the default cookie name is PHPSESSID which means they've both got the same name and conflict.

Both session.cookie_path and session.name can be changed in various places including your scripts (but you probably don't want to mess with those), in the php.ini file (but it will change for both applications so do you know good) on in .htaccess files .... so ... in the file $_SERVER[DOCUMENT_ROOT]/forum/.htaccess add something like
php_value session.name PHPOTHERSESSNAME

Well ... that's my theory. Please do let me know if it works ....

P.S. Your server does need to be configured to allow .htaccess files to do this; here's hoping that yours IS, or you can change your apache config to do so.
Reply With Quote
  #3 (permalink)  
Old Aug 26th, 2005, 16:53
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
yea i dont have access to the .htaccess files or anything like that...

but thanks neway

ne other ideas?! lol
Reply With Quote
  #4 (permalink)  
Old Aug 26th, 2005, 17:36
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Less good (since it means changing code ...) .... try adding

Code: Select all
<?php
ini_set("session.name","PHPMYNAME");
?>
at the very top of (each) top level script in the subdirectory. May also be worth checking the script to make sure it doesn't set this itself!
Reply With Quote
  #5 (permalink)  
Old Aug 26th, 2005, 20:28
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
i wrote all the script myself by hand so it doesn't set that anywhere...

i have one file which is included by include "filename.php" at the top of every file... will putting it at the top of that do the trick?
Reply With Quote
  #6 (permalink)  
Old Aug 28th, 2005, 09:29
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by benbacardi
i have one file which is included by include "filename.php" at the top of every file... will putting it at the top of that do the trick?
It should do .. in fact, I've just been "playing" with this as I'm putting a session wrapper around my site and don't want to disturb any "guts" and it can be even easier. The basic code change is an extra session_name call before the session_start. I am concerned (and still working on) places in the sites that are going to try to run sessions within sessions.

Code: Select all
session_name("MyWHC");
session_start();
Reply With Quote
Reply

Tags
php, sessions

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Little help on sessions? ktsirig PHP Forum 0 Mar 2nd, 2006 22:12
Sessions djme PHP Forum 4 Feb 25th, 2006 12:10
xsl, php sessions (please help) marco_van_mayo Other Programming Languages 0 Feb 19th, 2006 14:35
php sessions fragalot PHP Forum 7 Nov 8th, 2005 20:43
Sessions vor ASP.NET Forum 3 Aug 19th, 2003 20:10


All times are GMT. The time now is 11:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43