SunQuest
           Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

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 Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old April 13th, 2004, 04:20 AM
Porco Porco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hobart, Tasmania, Australia
Posts: 158 Porco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
basic session example in tutorial??

I am in desperate need to get a handle on sessions and for the life of me I haven't been able to get a single variable to pass to another page. I am using PHP version 4.3.4 and the latest Apache on an Athlon XP 1600 machine with Windows XP Professional.

My question is this... in the first example of the session tutorial cut and pasted below no value passes. Why? Is there something wrong on my machine? I would have thought the first example would have worked is all.

If you could help me clear this thanks in advance. Code below..

<?php
// page1.php
session_start();
$_SESSION["real_name"] = "Hermawan Haryanto";
print "<a href='page2.php'>Go to this page</a>";
?>

<?php
// page2.php
session_start();
print $_SESSION["real_name"];
?>


Shouldn't page2.php output Hermawan Haryanto

Reply With Quote
  #2  
Old April 13th, 2004, 07:24 AM
Porco Porco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hobart, Tasmania, Australia
Posts: 158 Porco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: basic session example in tutorial??

I checked the university server using vpn and the code worked?? Does anyone know if it is a setting problem with php or apache? Its a bit useless having them on the machine if it can't use sessions....


Reply With Quote
  #3  
Old April 13th, 2004, 11:21 AM
Porco Porco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hobart, Tasmania, Australia
Posts: 158 Porco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: basic session example in tutorial??

I have a handle on sessions now. I just can't work out why they don't work on my setup at home. Is there something I need to set in php.ini??

Any advice would be interesting...

Reply With Quote
  #4  
Old April 14th, 2004, 12:31 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,937 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 57 m 37 sec
Reputation Power: 3
Orkut
RE: basic session example in tutorial??

The problem seems to be that you arent registered the session variable.
php Code:
Original - php Code
  1.  
  2. session_register("somename");
  3. $_SESSION['somename'] == "some value";

However the problem could be in your browser as sessions create a cookie which stores the session id for referance later on. If you have cookies disabled you can either enable them or tell php to append the session id to the url using the following format.
php Code:
Original - php Code
  1.  
  2. ini_set("session.use_cookies" 0);
  3. session_register("somename");
  4. $_SESSION['somename'] == "some value";

There are multiple ways to get around the cookie problem above is just one.
I hope this helps you solve your problem.

Reply With Quote
  #5  
Old April 14th, 2004, 02:50 PM
Porco Porco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hobart, Tasmania, Australia
Posts: 158 Porco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: basic session example in tutorial??

i don't have cookies turned off - and the confusing thing is the code from the tutorial worked on the school server but not mine... a bit of a worry.

The code that was there was simply cut and pasted off this sites session tutorial, page 2.

Anyway thanks for some ideas.

Reply With Quote
  #6  
Old April 14th, 2004, 02:51 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: basic session example in tutorial??

no, never use session_register() and $_SESSION together. session_register() should only be used when global variables are disabled.

check your php.ini for the session save path, make sure the folder is in the web tree with read/write permissions.

Reply With Quote
  #7  
Old April 14th, 2004, 03:07 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,937 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 1 h 57 m 37 sec
Reputation Power: 3
Orkut
RE: basic session example in tutorial??

oh sorry about that session_register(); i slipped up.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > basic session example in tutorial??


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway