w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Keeping IIS Express Alive
Not sure if your site is actually hosted in IIS or its just running from VS. If you site is hosted in IIS you can set the timeout period in the App Pool that your site is using. Which is normally set to go to sleep after 20minutes. But you can set is as you like. If you don't want to set that in IIS you can set that is "machine.config" file but its not recommended. Have a look at this post if this meets your requirement. http://technet.microsoft.com/en-us/library/cc771956(v=ws.10).aspx

Categories : Asp Net

Keeping c3p0 connections alive
it sounds like you are keeping Connections checked out for a very long time. that's not a good idea with a Connection pool. Connections (or Hibernate sessions) should be acquired on an as-needed basis, used, and then closed immediately rather than being held alive and open. this is an architectural issue more than a configuration problem. good luck!

Categories : Hibernate

Scheduled task keeping application alive
Calling shutdown() on the scheduledExecutorService allowed the program to shut down normally. scheduledExecutorService.shutdown(); According to the javadocs, Initiates an orderly shutdown in which previously submitted tasks are executed Whereas calling cancel(true) just cancels the task, leaving the executor service alive, shutdown() kills the executor service as well, allowing the program to exit.

Categories : Java

keeping background service alive after user exit app
One Way of Doing This. Suppose you have a Service Class named "DoSomething". In Android Manifest Declare: <service android:name = ".DoSomething"></service> In the Service Class: Handler handler = new Handler(); Runnable runnable = new Runnable(){ @Override public void run() { // TODO Auto-generated method stub YourMethod(); handler.postDelayed(this, 1000); // 1000 - Milliseconds } }; And Finally: @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub handler.postDelayed(runnable, 1000); return START_STICKY; } From your Activity: Intent intent = new Intent(this, DoSomething.class); startService(intent); I hope it helps.

Categories : Android

One session design pattern for EJB JPA and GWT RequestFactory aka keeping JPA session between multiple method calls
In your web layer you have two calls to a stateless session bean, so this results in two transactions. There are three options Use a UserTransaction in your web layer code: final InitialContext ic = new InitialContext(); final UserTransaction ut = (UserTransaction) ic.lookup("UserTransaction"); ut.begin(); try { // find // set new value in entity // save ut.commit(); System.out.println("committed"); } catch (Exception ex) { ut.rollback(); System.out.println("rolled back"); } This way the client controls the transaction. If someone forgets to use a UserTransaction, this will result in multiple transactions. There is no need to change the EJB side. Add a method in the facade which calls both DAB methods on behalf of the client: public void findAnd

Categories : Java

How to Keep an OAuth Session Alive
You should save the most recent access token in a DB or on the server, and make the requests with the saved token. Instagram access tokens are long-lived (for now at least). Feel free to use the wrapper I have here. That way sessions are a non-issue except for the first time you get a token. $insta = new Instagram(array( 'client_id' => $client_id, 'client_secret' => $secret, 'redirect_uri' => $redirect_uri )); if(!$insta->isAuthenticated()){ /* Not logged in */ $login_url = $this->insta->getLoginUrl(array( 'scope' => $scope, )); header("Location: ".$login_url."); } /* Save the token */ if($this->insta->getToken()) { $to

Categories : Api

How to keep a session alive after logging in (Codeigniter)
You have to create new table in base, like shoppingcarts, and pass all items from that Chart class in that table, and user ID, then when user log in just query that table with his ID and ID of row now you got all products.But when user bye just delete that rows in base and unset cart class $data = array( 'id' => 'sku_123ABC', 'qty' => 1, 'price' => 39.95, 'name' => 'T-Shirt', 'options' => array('Size' => 'L', 'Color' => 'Red' 'user_id => '45') ); $this->cart->insert($data); $chart = $this->cart->contents(); $this->db->insert('shoppingcarts',$chart); This is just simple example, how to do

Categories : PHP

How to keep session alive using jquey or javascript
function refreshSession() { var a = window.open("keepAlive.aspx", '_blank'); a.focus(); a.close(); } var milliseconds = 10000 //whatever you want here... window.setInterval("refreshSession", milliseconds); this will open a new window, make a request and close it. Use with a timer to keep sessions alive.

Categories : Jquery

Server session still alive, but data being lost
It sounds like your session timeout variable may just be too low. It's also possible your app pool is recycling due to memory usage or some other issue; could you tell us your IIS settings on that app pool for recycling?

Categories : C#

How to keep remote powershell command alive after session end?
The way to keep the remote PowerShell session running after the command has finished is to use a PSSession e.g.: $s = new-PSSession computername Invoke-Command -session $s { ..script.. } ... do other stuff, remote powershell.exe continues to run Remove-PSSession $s # when you're done with the remote session Generally though exes should run independently from the app that launched them.

Categories : Windows

ASP.NET - Accessing Active Directory from code behind page
I found the answer to my question in one of "Related questions" on this page. The answer was in this topic: Why does DirectoryServicesCOMException occur querying Active Directory from a machine other than the web server? I found, that it was exactly my case. After reading the suggested Microsoft article, I learned, that impersonating works only for local resources on the IIS server. To access network resources (SQL, Active Directory), I have to set "Trust this computer for delegation" in the computer object in Active Directory.

Categories : Asp Net

Keep server session alive automatically based on activity / input, using JQuery
In short, you could use a variable on the page and update it on activity such as on key presses and mouse clicks. If there has been activity, do a ping to keep the server session alive. Rather than recreate an entire write up, you can see the technique demonstrated here: How to keep alive a user's session while they are posting on a forum? EDIT: To help you out, I've spent a good chunk of time and taken the code you borrowed, substantially modifying and restructuring it so that you should be able to better understand what's going on in the code. This should improve your chances of successfully updating it further. I didn't spend any time optimizing it, but it should work. I've updated the fiddle so you can try it out: http://jsfiddle.net/xHEF9/555/ and also included the updat

Categories : Jquery

Can i check if a session is active throught the code instead at page load?
Yes, check your session_id(). If it returns an empty string, session is not set. If you want to be able to tell from the client-side, you'll need to use AJAX.

Categories : PHP

Keeping database session open
Just enclose the relevant part of your script in withSession{}. Note that if you are keeping the session open for a while/are performing lots of database manipulation queries, you should also look into taking advantage of transactions. And you should really be using prepared statements for inserts if the data has a potentially external source.

Categories : Scala

Keeping CodeIgniter session active
set your session preferences setting in application/config/config.php sess_expiration :The number of seconds you would like the session to last. The default value is 2 hours (7200 seconds). If you would like a non-expiring session set the value to zero: 0 see the documentation of codeigniter : session settings

Categories : PHP

C# LibCurlNet , keeping the same session id in Cookie.txt
Instead of using Curl could you not use the built-in HttpWebRequest class instead? The HttpWebRequest has a CookieContainer property that you can assign a CookieContainer object. This object can be re-used between requests, so I think it should do what you are after.

Categories : C#

keeping a LDAP user logged in with PHP session
You should only authenticate/include LDAP on your login page.. if success set a $_SESSION['LDAP']['login'] = true; And check on every page with this. if (!isset($_SESSION['LDAP']['login'] && $_SESSION['LDAP']['login'] !== true) { header('Location: login.php'); exit; // dont forget the exit here... }

Categories : PHP

Which is better? - Querying database every time or keeping objects in session
Caching data in a session scoped object runs the risk of providing stale data - if another process modifies the database's contents then the session scoped object won't reflect these changes. It doesn't sound like this is mutable data, though, in which case this isn't a problem. Other than that, caching data in the session scoped object may be better in terms of time since the data is kept in main memory, and going to the database each time may be better in terms of space since you're not keeping the data in memory. The "may" qualifiers are there because the database may be caching this data for you.

Categories : Database

Session variables don't get passed to the third page after session start
I don't know what is in your objects.php, calling session should probably come before that. session_start(); require("objects.php"); echo session_id(); echo $_SESSION["loggedin"];

Categories : Misc

How to retrieve session variable when the session had already started in another page?
Either you are including the file multiple times on a page; or you are including it on a page that has its' own session_start() statement; or your php.ini (possibly .htaccess) is automatically starting a session before you do - http://www.php.net/manual/en/ref.session.php#ini.session.auto-start You can use the following logic to only start a session if it has not already been started - if(!isset($_SESSION)) { session_start(); } try having a core folder and a init.php where you start sessions there, session_start() and include this everywhere you go, this can also have database connection and all you want to be cool everywhere then play with sessions with out this kind of errors

Categories : PHP

Accessing session value in django template
Do not confuse Django template language with Python Syntax. Django template language its a language on its own and have its own way of performing things. As doc suggests: The goal is not to invent a programming language. The goal is to offer just enough programming-esque functionality, such as branching and looping, that is essential for making presentation-related decisions.

Categories : Django

Accessing Session Directly vs Other ways
For error handling there are several libraries that can simplify things for you. But beyond that, storing things on the session should only be done where you need the object In several places Ideally if you need to expose one object from one view to the other, you could use a common base model that includes what the views need, or add stuff to the ViewData object instead of the session object. And for error handling, fatal errors should be trapped in global.asax, and for warnings, I in particular use a base model class for all views that includes a warnings collection that is shown via master page.

Categories : Asp Net Mvc

jQuery: Date Range Picker: refresh page after selecting datepicker and keeping the selected date after page reload
Although I don't understand why you'd need to keep the data after a page refresh, your best bet is to use cookies to solve the problem. This would require to use an event-handler (such as onchange) attached to your datepicker input textbox. <input type="text" onchange="setCookie();" name="datepicker"> This way, whenever the user changes the data (eg: selects a date), the javascript function setCookie is called. The function would then have to store the date that was picked by setting a cookie (example). Once you have your cookie set, you have to make sure that your input is pre-populated with whatever value was last stored in the cookie. This means reading the cookie (example) and the setting the value of the input either through an value="" tag or jQuery $("input").val("").

Categories : Jquery

accessing session variable in ClassGeneratorConfiguration in symfony1.4
You can get it from the context (I think there is no other way) and than you can use the getFilterDefaults method to set a default value for a field or use the getFilterFormOptions to pass the user into the form as an option and implement the logic there. This is how I usally do it: class productGeneratorConfiguration extends BaseProductGeneratorConfiguration { /** * @return sfBasicSecurityUser */ public function getUser() { return sfContext::getInstance()->getUser(); } public function getFilterFormOptions() { return array('user' => $this->getUser()); } public function getFilterDefaults() { return array( 'some_field' => $this->getUser()->getSomething() ? 'a' : 'b'; ); } }

Categories : Symfony2

Accessing a session attribute in a JAVA Class
There are at least 2 problems in your code: The @WebFilter("/RequestFilter") annotation does not make sense to me. It MUST be set in a way to hit all incoming requests interested in the ThreadLocal value, e.g. "/*". You pass the request twice to the chain. You must first set the ThreadLocal value, then forward to the chain, and finally remove the ThreadLocal value. Just remove the first chain.doFilter(...) invocation. public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // pass the request along the filter chain chain.doFilter(request, response); <-------------------- PROBLEM if (request instanceof HttpServletRequest) { localRequest.set((HttpServletRequest) request); } try {

Categories : Java

Accessing properties of object stored in session
Session object is not shared across different users so GetKeyForCurrentUser is useless. you can use some simple string for key. objects stored in Session must be serializable thus SomeBusinessObjectType must be serializable too.

Categories : C#

Adding and Accessing Multiple Session Variables in Rails
the simplest way is that stores product's id as an array. @product = Product.find(params[:product_id]) (session[:pending_purchase] ||= []) && (session[:pending_purchase] << @product.id ) and your will find more products when you use it: @products = Product.find(session[:pending_purchase]) @products.each do |p| ......... end

Categories : Ruby On Rails

How to get IP address of the Client accessing my page where My web page or WebApp is hosted at some remote server
Check out this article at W3Schools: http://www.w3schools.com/asp/coll_servervariables.asp you can try: Request.ServerVariables("remote_addr")

Categories : C#

accessing parent page variables from page opened with AJAX
The simple answer is that you cannot. When the browser deals with the parent page, it has no knowledge of what/how generated it - all it sees is an HTML page, hence there are no variables of any kind that it knows about. When you're invoking another PHP script using AJAX, the browser simply makes another call to the server. A new process is started on the server to run that script - and it has no knowledge of the parent page generation (which most likely has finished loading by now, anyway, and the script exited). The only way to avoid using GET or POST values in the ajax request is to use cookies. You can set a cookie value (using setcookie() function) from the parent page and then read is in the ajax page (using $_COOKIE superglobal). EDIT: Just realised the obvious: you can also us

Categories : PHP

To prevent expiring session variables in submit page, should I assign session variable to viewstate variable?
Yes, you can do it. but viewstate tends to slow the page loading due to extra overhead. If your dataset is small it is ok, but if its bigger then look for other alternatives. How ever I will recommend not to go with this method[security problem,slow etc.], instead device a way so that session dosent expire if any page is open?? how?? use jquery/ajax to maintain a connection with server at regular interval. If you want to go some further implement sql session. It will be the best. Hope these info help you.

Categories : C#

Dependency Injection in Struts2 Accessing Session Scoped Beans
I believe Luiggi's comment is correct. The "@Inject" needs to be on the field value itself, not on the setter. @Inject("session") private Session session; As long as you've got the "session" bean defined in struts.xml or registered it with the Struts container it should be able to find it and inject it. From your explanation that seems to be the case. For some more specific information check this Discussion on the Struts User list: Struts user question on built-in DI

Categories : Java

Facebook Connect Accessing a User's FB Session/Access Token ID?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { internetActive=YES; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; self.navController=[[UINavigationController alloc] initWithRootViewController:self.viewController]; [self.navController.navigationBar setBarStyle:UIBarStyleBlackTranslucent]; self.window.rootViewController = self.navController; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil]; _internetReachable = [Reachability reachab

Categories : IOS

Keeping the same form on the reload of the page
Easiest thing to do is to use localStorage or sessionStorage to save the state of the form. You might want to think about looking for a framework that handles page states if you want to do more of this. The gollowing sets the value of lastForm in localStorage in each event handler. After the handlers are defined, it changes the current form if localStorage.lastForm equals sign_up. jQuery(function ($) { var $sUp = $("#sign_up"), $sIn = $("#sign_in"); $("#content").on('click', "#sign_up_btn", function () { $sIn.stop().fadeOut(800, function () { $sUp.fadeIn(800); }); $(this).stop().fadeOut(800, function () { $(this).attr({ value: "Already have an account?", id: "sign_in_btn" }).f

Categories : Javascript

How do I resolve the OAuthException 100 Requires user session error when accessing Facebook?
To query for the "page statuses", you need to pass the user_access_token, not the app_access_token. The user access token is obtained at the authorization step. For eg: //authorization session = await App.FacebookSessionClient.LoginAsync("manage_pages"); string access_token = session.AccessToken; string fb_id = session.FacebookId;

Categories : C#

Keeping a timer running on another page when navigating around
Your NSTimer is a member variable of your view controller class. I'm assuming that when you switch between views, you're destroying this view controller and instantiating an instance of a new one. That means this view controller is gone, as well as the timer; it's not that the timer is being reset, it's that your old timer has been destroyed an a new one is being created. What you need is to store your NSTimer and its functionality in a place where it will not be destroyed every time you change your view controller. One solution is to create a Singleton class which handles the timer. (A Singleton class is a class that can only be created one time; only one instance of it can exist. You can read more about them here.) Here is an example of how you can create a Singleton class in Objective

Categories : IOS

Redirect a page to another url, but keeping the view name in the address bar
One way to do this would be to use an iframe in the view you are generating for the user. @RequestMapping(value = {"hello/{id}"}, method = RequestMethod.GET) public String helloGet(Model model, @PathVariable Integer id) { final String url = "http://www.google.com" model.addAttribute("externalUrl", url); return "hello"; } Then in the hello.jsp file could look like: <!DOCTYPE html> <html> <head> </head> <body> <iframe src="${externalUrl}"></iframe> </body> </html> Another way would be to make a request to the external website and stream the response to the user.

Categories : Java

Getting "working outside of request context" error when accessing session during unit test in Flask?
If you want make request to your application: app = create_flask_app() response = app.test_client().get('/test/url') # test response If you want test code which use application context (current_app, g, url_for): app = create_flask_app() with app.app_context(): # test your app context code If you want test code which use request context (request, session): with current_app.test_request_context(): # test your request context code But better look at flask-testing, because it simple and already have useful setups.

Categories : Python

HTML: keeping checkbox checked after page refresh
For modern browsers you can use localStorage like so $(function(){ var value = localStorage.input === 'true' ? true: false; // 1 $('input').prop('checked', value || false); }); $('input').on('change', function() { localStorage.input = $(this).is(':checked'); }); Demo: http://jsfiddle.net/CC2hC/1 When the input is changed you store the value in localStorage, and when the page loads again you check if it is there and apply the value or default to false For older browsers you will probably have to use cookies or a database. You have to check the value on the line with the comment // 1 because prop accepts a boolean value whereas the localStorage value would be a string

Categories : PHP

How to do a 301 redirect in htaccess while keeping the slug of the original page
When migrating a blog, you need to use a 301 redirect. 301 redirects, by definition, will change the path in the url bar. From memory, you'll need to do all of these steps if you need to make it lowercase too. In your VirtualHost, add RewriteMap lc int:tolower In your .htaccess, add: RewriteCond %{REQUEST_URI} [A-Z] RewriteRule (.*) ${lc:$1} [R=301,L] RewriteRule /blog/bid/([0-9]+)/(.*) /$2 [R=301,l]

Categories : Regex

Keeping code structure with string literal that uses whitespace
if (true) { if (!false) { //Some indented code; stringLiteral = string.format( "This is a really long string literal. " + "I don't want it to have whitespace at " + "the beginning of each line, so I have " + "to break the indentation of my program " + "I also have vars here: " + "{0} " + "{1} " + "{2}", var1, var2, var3); // OR, with lineskips: stringLiteral = string.format( "This is a really long string literal " + "I don't want it to have whitespace at " + "the beginning of each line, so I have " +

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.