There is a very strange issue with PHP session when you prefer session to save in files other than database (normal session).

The problem is: some times you can access all the saved session values from $_SESSION and sometimes it returns a empty array.

If you refresh 10 times, perhaps 4 times you will get session and 6 times you will get it empty.

The problem is not due to domain level security or session expiry . It is due to session file location. If you run a phpinfo() function in any of your page, you can see there is a part of sessions. There you can see a session variable session_save_path and it will be pointing to /tmp/ or /etc/somefolder or /var some folder inside the linux file architecture.

Since at clouds, different servers server at different time, some server can see the exact saved files in that location and some server cannot. (Since /tmp etc directories are not shared among them)

Solution:  Call the below php function and set session file path inside your web root . You need to call this function before your session_start() call

eg:

session_save_path(‘/mnt/stor1-wc2-dfw1/4675/5044/to/your/website/rootfolder/or/inner/directory);

For windows users as well, this is the solution. This problem occurs in ASP application as well.

Thanks

Sajith

Tags: , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

XAJAX

03 Jun 2009

Basically using xajax “You can directly call php functions from your javascript code”

Xajax will do the rest. 

For example, if you are going to write a javascript function Capitalize which captilaze your textbox content when you press a button.

Here is the pure html/javascript code for that:

=============================================

<script>

function Capitalize()

{

      var t = document.getElementById(‘cap’).value;

      document.getElementById(‘update’).innerHTML = t.toUpperCase() ;

}

</script>

 

<input type=”text” id=”cap” name=”cap” />

<input type=”button” id=”capbutton” value=”Capitalize” onclick=”Capitalize()” />

<div id=”update”></div>

==============================================

Now see the difference when we use xajax, we can write this Capitalize function in php code and can call from javascript.

function Capitalize($value)

{

    $objResponse = new xajaxResponse();

    $objResponse->assign(“update”,”innerHTML”,strtoupper($value));

    return $objResponse;

}

and you can call from your button’s onclick function:

 onclick=”xajax_Capitalize(document.getElementById(‘cap’).value)” 

Here the same functionality we moved from client to server. Thus the point is you can simply call all the functions you written in php (Server Side) from javascript code via onClick, onMouseOver or window.onLoad etc.

You can get the full source code of Capitalize example here:

http://www.sajithmr.com/downloads/capitalize.zip

To download and for documentation go: 

http://xajaxproject.org/

Thanks

Sajith

Tags: , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Server Migration

02 Sep 2008

piCDN

I was finding that my visitor count is increasing and alexa ranking of www.sajithmr.com is now well below 100,000

So I decided to change my old Cpanel hosting to a professional content delivery network who can provide me the scalability that www.sajithmr.com may demand in the future . After much research i ended up with PiCDN who provide affordable CDN service
The following are the changes that the new hosting offers me:

They use a different web server than apache . I found that it was nginx and it seems its the rising star in web servers

I dumped my old cpanel mail to  Google Mail for domains – Picdn integrates it with fully and it got only minutes to get me running :)

I have ssh access to my account !. Occassionally i can do cleanup jobs and have more flexibility than a FTP account. Besides picdn people claim it more secure

These are their features (copied from http://www.picdn.com)

  • Highly scalable hosting infrastructure
  • Asynchronous web server
  • Geo-distributed fault tolerant nameservers
  • PHP ready
  • Dedicated fine tuned MySQL database server
  • Geo-aware redirection of users to the nearest cache/node
  • SFTP /SSH/RSYNC publishing access
  • Allows plugging in of other Application servers and content processing servers
  • Google Mail for Domains Ready

I am fully satisfied with my new host and plan to move over http://www.amvizone.com to them soon

So Sajithmr.com is now in new server with new design (home page only ), have a look at: http://www.sajithmr.com

Tags: , , , , , ,

· · · ◊ ◊ ◊ · · ·

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431