Jump to content

[SOLVED] A simple problem with SESSION


watthehell

Recommended Posts

hi all...

 

my code goes like this :

 

I have a function

 

<?php function DisplayCalender($id,$month,$year)
{
  // other stuffs are here... it is long so i didnt post
  
  // I have this part in this function 
  
if($i==$date && $year_curr==$year && $month_curr==$month)
	{
		// save the curr date in session
		$_SESSION['mycurrdate']=$i.'-'.$month_curr.'-'.$year_curr;
		$_SESSION['myselecteddate']=$month_curr.'-'.$year_curr;
		$class_bg="cal_current_bg";
		$date_class="cal_font_current";
		$symbol1="car_curr";
		$symbol2="curr_sym";
	}
  // end of function 

}?>

 

here in the function I have stored the current date in SESSION

$_SESSION['mycurrdate']=$i.'-'.$month_curr.'-'.$year_curr;

 

and in the html code

 

<table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61">
  <!--DWLayoutTable-->
  <tr>
   <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><?php echo @$_SESSION['mycurrdate']; ?></td>
   <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="#" class="cal_font_month">>></a></td>
  </tr>
   <tr>
    <td height="226" colspan="2" valign="top" bgcolor="#EB208C"><?
$id=1;
$month=date("n");
$year=date("Y");
DisplayCalender($id,$month,$year);


 ?></td>
  </tr>
</table>

 

I echo-ed the session value, but when the page loads it comes blanks and when i refresh the page the date value comes...

 

Any idea why this happens..

 

Thanks..

Link to comment
https://forums.phpfreaks.com/topic/68963-solved-a-simple-problem-with-session/
Share on other sites

thanks for ur reply.. but

 

when i keep session start

 

<?php session_start();
require_once("config.php");
require_once("user_info.class.php");?>

 

i get a error

 

Notice: A session had already been started - ignoring session_start() in c:\wamp\www\pankopat\calendar.php on line 1

 

 

Thanks a lot [redarrow] now it is working...

 

put this on the bottom of the page.

 

<?php

ob_end_flush();

?> 

 

stupid question, but do you have any code above the snipet that you are posting?

And this one for you kireol...

 

SEE THE DIFFERENCE OF BEING A GURU AND A NEWBIE  ;) ;) ha ha ha ha....

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.