<div>Hi Jamie Holly</div>
<div>This was really a wondeful solution. I had to modify a bit as below. In hook_init(), I added below code and was able to get the result as expected.</div>
<div> </div>
<div><em><font color="#3333ff"> if(isset($_SERVER['REDIRECT_URL']))<br> {<br> if($_SERVER['REDIRECT_URL'] == '/<a href="http://mysite.com/system/ajax">mysite.com/system/ajax</a>')<br>
{<br> // Page requested via jQuery - AJAX. No need to reset my session variables<br> }<br> else if($_SERVER['REDIRECT_URL'] == '/<a href="http://mysite.com/my_custom_module/form/register">mysite.com/my_custom_module/form/register</a>')<br>
{<br> // Non jQuery-AJAX page request. This is the place to reset my session variables<br> }<br> } </font></em></div>
<div><em><font color="#3333ff"></font></em> </div>
<div> </div>
<div> Thanks a lot.</div>
<div> </div>
<div>Kamal</div>
<div>Net Cloud Systems</div>
<div>Bangalore</div>
<div><br><br> </div>
<div class="gmail_quote">On Tue, Sep 25, 2012 at 6:16 AM, Jamie Holly <span dir="ltr"><<a href="mailto:hovercrafter@earthlink.net" target="_blank">hovercrafter@earthlink.net</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div text="#000000" bgcolor="#FFFFFF">
<div>There really isn't an API that exists just for that purpose. Remember, AJAX is also just a simple page load. <br><br>One workaround is to check for the HTTP_X_REQUESTED_WITH header. JQuery adds that in on all AJAX requests, so as long as you don't have any modules doing their own AJAX or changing the jQuery AJAX setup, it should work (modules invoking their own AJAX would be a fringe case).<br>
<br>So in hook_init, just go with something like:<br><br>if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {<br> // Page requested via jQuery - AJAX. <br>
} else {<br> // Non jQuery-AJAX page request. <br>}<span class="HOEnZb"><font color="#888888"><br><pre cols="72">Jamie Holly
<a href="http://www.intoxination.net/" target="_blank">http://www.intoxination.net</a>
<a href="http://www.hollyit.net/" target="_blank">http://www.hollyit.net</a></pre></font></span>
<div>
<div class="h5">On 9/24/2012 8:28 PM, Kamal Palei wrote:<br></div></div></div>
<div>
<div class="h5">
<blockquote type="cite">
<div>Hi Nancy</div>
<div>Thanks for help.</div>
<div> </div>
<div>Initially I thought so and gave a try for _init() hook. It looks it gets called always either it is first time page load, or a page refresh 9F5 in windows env) or even during AJAX events. Even I tried _exit() hook, looks it is also invoked always.</div>
<div> </div>
<div>I am looking for a hook that gets invoked for first time page load and on page refresh, but should not be invoked during AJAX events.</div>
<div> </div>
<div>So still searching if any such hooks are available that gets invoked only during <strong>first time page load and on page refresh</strong>.<br></div>
<div>Thanks</div>
<div>Kamal</div>
<div>Net Cloud Systems</div>
<div>Bangalore</div>
<div><br> </div>
<div class="gmail_quote">On Mon, Sep 24, 2012 at 4:03 PM, Ms. Nancy Wichmann <span dir="ltr"><<a href="mailto:nan_wich@bellsouth.net" target="_blank">nan_wich@bellsouth.net</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div>
<div style="FONT-FAMILY:arial,helvetica,sans-serif;FONT-SIZE:12pt"><a href="http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_init/7" target="_blank">http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_init/7</a>
<div><span><br></span></div><font color="#ff007f" size="4" face="bookman old style, new york,
times, serif"><i><b>Nancy<br></b></i></font>
<div><font face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</font></div>
<div style="BACKGROUND-COLOR:transparent;FONT-STYLE:normal;FONT-FAMILY:arial,helvetica,sans-serif;FONT-SIZE:16px"><br>
<blockquote style="BORDER-LEFT:rgb(16,16,255) 2px solid;MARGIN-TOP:5px;PADDING-LEFT:5px;MARGIN-LEFT:5px">
<div style="FONT-FAMILY:arial,helvetica,sans-serif;FONT-SIZE:12pt">
<div style="FONT-FAMILY:times new roman,new york,times,serif;FONT-SIZE:12pt">
<div dir="ltr"><font face="Arial">
<hr size="1">
<b><span style="FONT-WEIGHT:bold">From:</span></b> Kamal Palei</font><br></div>
<div><br>
<div>
<div>Hi List</div>
<div>I want to know is there any API in D7 is invoked when a page loads for first time or during page refresh/reload.</div>
<div>During anyother time that particular api should not be invoked.</div>
<div> </div>
<div>I have a custom form, and I keep certain variables in $_SESSION. During first time page loads I want to reset the session variables.</div>
<div>Also during page refresh (for windows IE F5) also I want to reset session variables.<br></div></div></div></div></div></blockquote></div></div></div><br>--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</blockquote></div><br><br>
<fieldset></fieldset> <br></blockquote><br></div></div></div><br>--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></blockquote></div><br>