• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

CSS file not imported in laravel blade view

I want a way to give path to my files which are outside of public folder in laravel

How can I get new CSRF token in LARAVEL by using ajax

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

add " ? " in url via htaccess RewriteRule

How to show selected value using javascript in laravel

How do I call a php file with axios?

Required field only if another field has a value, must be empty otherwise

Best way to scrolldown onpageload

Laravel relationship belongsToMany with composite primary keys

How to validate tin and cst using PHP?

Find out the name of the last script that included the current one

Laravel 5 session not persisting after user is logged in

Get lat/lon from google maps url ftid (hex)

Which is faster php date functions or carbon?

About Contact Privacy policy Terms and conditions