PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 4th, 2000, 03:15 PM
sergio's Avatar
sergio sergio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Pembroke Pines, FL
Posts: 11 sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 43 m 3 sec
Reputation Power: 0
I have just tryed to use sessions but all I can see is a totally blank page , do you know why ? May be something wrong with the /tmp dir in php.ini ?
Please help me , I have to do a shopping cart and I just started in the wrong way .
This is the code :
<?
session_start();

if (!$PHPSESSID) {
session_register('body_color');
session_register('text_color');

} else if ((!$body_color) | | (!$text_color)) {

session_register('body_color');
session_register('text_color');

}
?>

Sergio.

Reply With Quote
  #2  
Old July 5th, 2000, 09:33 AM
sergio's Avatar
sergio sergio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Pembroke Pines, FL
Posts: 11 sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 43 m 3 sec
Reputation Power: 0
The variable and the session is created in the /TMP directory but the page still look blank and the execution of the php page stop suddently when I declare a session ( es, session_start(); or Session_register(); ) .
Please help me , I'm sure there is a lot of people interested in this....

Sergio.

Reply With Quote
  #3  
Old July 5th, 2000, 12:06 PM
ualberti ualberti is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 1 ualberti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The code seems correct but a little bit redundant

Try to consider this...

"<?
session_start(); ...
"

This call will load in memory the content of the current session, or will create a new one if no session is currently in use.
If your browser has already send a sessionId along with the request, then all variables stored in the session will be available.
Hence

"if (!$PHPSESSID) {
session_register('body_color');
session_register('text_color');

}
"

will not be executed even if a new session is established, due to first access to the resource ($PHPSESSID is always set).

Furthermore

"else if ((!$body_color) | | (!$text_color)) {

session_register('body_color');
session_register('text_color');

}
?>
"

is executed only on the first access to the resource, when no variable named 'body_color' or 'text_color' is in scope. The second time (do you mean that you use the same resource to test session? it seems ...) the resource is get from the same browser instance, the session_register() call will bring in scope
'body_color' and 'text_color', so the "if" part of "else" branch wil not be executed. Maybe this is the correct place where you will initialize those session variables.

Try this
"
<?
session_register('body_color');
session_register('text_color');

if ((!$body_color) | | (!$text_color)) {

$body_color=$somecolor1; // you will assign
// a color value here
$text_color=$somecolor2; // you will assign
// a color value here

}

// set body and text color to the values in
//$body_color and $text_color

....
?>
"
Note that session_register() calls
session_start().

I don't know your session expiration settings. Maybe something is wrong with the session expiration. The default value is 0 meaning that session wil expire when the browser instance will be closed.

Try to edit the session file in /tmp dir in order to verify correct value for session variables and verify that only one file is created. If more that one file is created then more than one session is spawned between two request.

Hope will help

PS: sorry if same error is included ... I have a little experience.

Ciao Ugo.


Reply With Quote
  #4  
Old July 5th, 2000, 03:50 PM
sergio's Avatar
sergio sergio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Pembroke Pines, FL
Posts: 11 sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level)sergio User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 43 m 3 sec
Reputation Power: 0
Ok , thx a lot , I'll try it.
(Non mi dire che sei italiano perchè ci potremmo risparmiare una fatica grandissima....almeno questo da parte mia.. )

Sergio.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP4 and Sessions

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap