Senior & Expert PHP Developers Discussion Forum by Nyros Technologies

HIRE PHP Expert Developers Programmers Coders From India
PHP .Net Ruby on Rails Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Sessions don't work at all?

 
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Sessions Management
View previous topic :: View next topic  
Author Message
Mattachoo



Joined: 20 Feb 2009
Posts: 5

PostPosted: Tue May 19, 2009 9:06 am    Post subject: Sessions don't work at all? Reply with quote

I've worked with sessions before in PHP. All of a sudden, they stopped working. My webhost recently did this "migration" thing where they changed a bunch of stuff (like upgrading from PHP 4 to PHP 5, etc.). Now, sessions don't work at all. I tried a simple test to see if they worked, and guess what, they don't. Here is my example:

<?php
  //first_page.php
  session_start();
  print("<html><pre>");
 
  $_SESSION["MyLogin"] = "FYICenter";
  print("A value saved in the session named as MyLogin.\n");
 
  $_SESSION["MyColor"] = "Blue";
  print("A value saved in the session named as MyColor.\n");
 
  print("Click <a href=next_page.php>Next Page</a>"
    ." to retrieve the values.\n");
  print("</pre></html>\n");
?>

<?php
  //next_page.php
  session_start();
  print("<html><pre>");
 
  $myLogin = $_SESSION["MyLogin"];
  print("Value of MyLogin has been retrieved: ".$myLogin."\n");
 
  $myColor = $_SESSION["MyColor"];
  print("Value of MyColor has been retrieved: ".$myColor."\n");
 
  print('</pre><a href="first_page.php">Click here to go back</a></html>\n');
?>

When I run the script, here is what I get in return:
[code=text]Value of MyLogin has been retrieved:
Value of MyColor has been retrieved:
Click here to go back\n[/code]
Absolutely nothing.

So my question is, what could be preventing my sessions from working? Also, when I click on the next_page.php link, it transfers a ?PHPSESSID variable in the URL. Maybe this has something to do with the problem? I don't know. Any help will be appreciated. Thanks!
Back to top
View user's profile Send private message
samir



Joined: 12 Nov 2007
Posts: 271

PostPosted: Tue May 19, 2009 9:41 am    Post subject: Reply with quote

hi Mattachoo ,
make sure that the first line of first_page.php start with session_start() , now you run the code and check

Hope this helps you.........................
Back to top
View user's profile Send private message
Mattachoo



Joined: 20 Feb 2009
Posts: 5

PostPosted: Tue May 19, 2009 5:35 pm    Post subject: Reply with quote

Ah ha! Ok, I'm getting somewhere. It was suggested to me that I put
  ini_set("display_errors", "1");
  error_reporting(E_ALL); 
at the start of my code. Now I get two error messages when I run my script.


Warning: Unknown: open(/var/php_sessions/sess_2a6b97f59f33efcf2366295b4e204ba5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0

So what should I set the session.save_path to in the ini file? I am going to talk to customer support today. Hopefully they will be able to fix it.
Back to top
View user's profile Send private message
samir



Joined: 12 Nov 2007
Posts: 271

PostPosted: Wed May 20, 2009 6:49 am    Post subject: Reply with quote

we need to make some modifications regarding sessions in php.ini file
once you contact your service provider , hope they can solve this

check the following links , they may be helpful to you
http://www.directadmin.com/forum/showthread.php?t=5663
http://forums.cubecart.com/lofiversion/index.php/t23665.html
http://limedaley.com/post/php4-to-php5-upgrade
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Sessions Management
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts how to delete plugins in openinviter
2 aababu 233 Wed Sep 01, 2010 7:27 am
aartylamba View latest post
No new posts ERROR IN PAYPAL PRO
0 tapati 20 Tue Aug 31, 2010 12:35 pm
tapati View latest post
No new posts file_exists always return false
0 orenk 114 Mon Aug 16, 2010 9:49 pm
orenk View latest post
No new posts problem with include fuction
0 bluearrow 117 Mon Aug 16, 2010 1:02 pm
bluearrow View latest post
No new posts Javascript not working in smarty .tpl files
1 samir 107 Mon Aug 16, 2010 5:42 am
venkatadapa View latest post
No new posts Add slashes automatically to all post params
0 samir 111 Mon Aug 16, 2010 5:18 am
samir View latest post
No new posts SMTP server settings when send mails through phpmailer class
0 venkatadapa 96 Mon Aug 16, 2010 4:49 am
venkatadapa View latest post
No new posts Parse the xml string content and display in browser using JS
0 venkatadapa 114 Mon Aug 09, 2010 1:22 pm
venkatadapa View latest post
No new posts Parse the xml file content and display in browser using JS
0 venkatadapa 119 Mon Aug 09, 2010 1:18 pm
venkatadapa View latest post
No new posts hipay
1 hassene003 142 Mon Aug 09, 2010 12:35 pm
aababu View latest post





Hire an expert PHP developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   .Net   |   Free unlimited HTML CSS Joomla Wordpress Drupal templates download

Nyros Technologies   |   Developers Blog   |   Kakinada City Portal   |   About PHP Experts   |   More